蒟蒻的来做梦8.28总结
应该没人写了笔记吧但还是放一个黑板:
U593675 查找数
这题二分。
#include<iostream>
using namespace std;
int n,a,b;
int main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
cin>>n>>a>>b;
for(int i=1;i<=n;i++){
int t;
cin>>t;
if(t==a+b){
cout<<i;
return 0;
}
}
return 0;
}
U593858 数叉叉
判断有几个x。
#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;
int h,w;
vector<vector<bool>>v;
vector<int>cnt;
int main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
auto calc=[](int x,int y){
{
int n=0;
while(1){
if(x-n>=0&&y-n>=0&&x+n<h&&y+n<w
&&v[x-n][y-n]&&v[x-n][y+n]&&v[x+n][y-n]&&v[x+n][y+n]){
n++;
}else{
break;
}
}
if(n>1){
cnt[n-2]++;
}
}
};
cin>>h>>w;
v.resize(h);
for(auto &&i:v){
i.resize(w);
for(auto &&t:i){
char c;
cin>>c;
if(c=='#'){
t=1;
}
}
}
cnt.resize(min(h,w));
for(int i=0;i<h;i++){
for(int t=0;t<w;t++){
if(v[i][t]){
calc(i,t);
}
}
}
copy(cnt.begin(),cnt.end(),ostream_iterator<int>(cout," "));
return 0;
}
U593859 落落的去的数学问题六
埃式筛。
#include<iostream>
#include<vector>
using namespace std;
using ll=long long;
ll n,cnt;
vector<ll>v;
int main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
auto run=[](){
vector<bool>f(1e6,1);
for(ll i=2;i<f.size();i++){
if(f[i]){
for(ll t=i;t*i<f.size();t++){
f[i*t]=0;
}
}
}
for(ll i=2;i<1e6;i++){
if(f[i]){
v.push_back(i);
}
}
};
cin>>n;
run();
for(ll i=0;v[i]*v[i]*v[i+1]*v[i+1]*v[i+1]<=n;i++){
for(ll t=i+1;v[i]*v[i]*v[t]*v[t+1]*v[t+1]<=n;t++){
for(ll k=t+1;v[i]*v[i]*v[t]*v[k]*v[k]<=n;k++){
if(v[i]*v[i]*v[t]*v[k]*v[k]<=n){
cnt++;
}
}
}
}
cout<<cnt;
return 0;
}
U593866 更多的o
你看我会写么?
代码在这
本页面的全部内容在CC BY-NC-ND 4.0 和 SATA 协议之条款下提供,附加条款亦可能应用