所有水题均被折叠
Lv.1 青铜
1201
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#define ll long long
#define INF 2000000000000000
using namespace std; int main(){
ll mx=-INF,mn=INF;
ll N;
scanf("%lld",&N);
for(ll i=;i<=N;i++){
ll x;scanf("%lld",&x);
mx=max(x,mx);
mn=min(mn,x);
}
cout<<mn<<" "<<mx<<endl;
return ;
}
1202
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#define ll long long
#define INF 2000000000000000
using namespace std; int main(){
ll sum=;
ll N;
scanf("%lld",&N);
for(ll i=;i<=N;i++){
ll x;scanf("%lld",&x);
sum+=x;
}
cout<<sum<<endl;
return ;
}
1203
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#define ll long long
#define eps 1e-8
#define INF 2000000000000000
using namespace std; int main(){
double x,y;
cin>>x>>y;
if(fabs(x-y)<eps) puts("yes");
else puts("no");
return ;
}
1204
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cmath>
#define ll long long
#define eps 1e-8
#define INF 2000000000000000
using namespace std; int main(){
char str1[];
char str2[];
scanf("%s%s",str1,str2);
cout<<(strstr(str1,str2)-str1+);
return ;
}
1205
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cmath>
#define ll long long
#define eps 1e-8
#define INF 2000000000000000
using namespace std; int main(){
string str;
vector<string> vec;
while(cin>>str)vec.push_back(str);
for(int i=vec.size()-;i>=;i--){
cout<<vec[i]<<" ";
}
return ;
}
1206
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#define ll long long
#define eps 1e-8
#define INF 2000000000000000
using namespace std; int main(){
double x,y;
cin>>x;
printf("%.2lf",x);
return ;
}
2235
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cmath>
#define ll long long
#define eps 1e-8
#define INF 2000000000000000
using namespace std; int main(){
int ans;
double a,b;
scanf("%lf%lf",&a,&b);
ans=a*b/;
ans=floor((ans+)/10.0)*;
cout<<ans<<endl;
return ;
}
//如果你不喜欢这些水题怎么办,请把他们A掉,一遍过
Lv.2 白银
1011
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<vector>
#include<cmath>
using namespace std; int N,a[]; int f(int x){
if(x==||x==) return ;
if(a[x]!=) return a[x]; int tmp=;
for(int i=;i<=x/;i++){
tmp+=f(i);
}
// cout<<tmp<<endl;
return a[x]=tmp;
} int main(){
scanf("%d",&N); cout<<f(N); return ;
}
1430
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std; int x;
int main(){
int flag=;
scanf("%d",&x);
for(int i=;i*i<=x;i++){
if(x%i==) flag=;;
}
if(!flag) puts("\\n");
else puts("\\t");
return ;
}
1075
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std; int N,a[],cnt; int main(){
memset(a,-,sizeof(a));
scanf("%d",&N);
for(int i=;i<=N;i++){scanf("%d",&a[i]);}
sort(a+,a+N+);
for(int i=;i<=N;i++) if(a[i]!=a[i+])++cnt;
printf("%d\n",cnt);
for(int i=;i<=N;i++) if(a[i]!=a[i+])printf("%d ",a[i]);
return ;
}
1076
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std; int N,a[],cnt; int main(){
scanf("%d",&N);
for(int i=;i<=N;i++){scanf("%d",&a[i]);}
sort(a+,a+N+);
for(int i=;i<=N;i++)printf("%d ",a[i]);
return ;
}
1083
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define MAXN 2000000
using namespace std;
int N,kase;
int main(){
scanf("%d",&N);
int k=;
while(N>k){
N-=k;++k;
} int i=,j=;
if(k&){
i=k+,j=;
while(N--){
--i;++j;
}
}
else{
i=,j=k+;
while(N--){
++i;--j;
}
}
printf("%d/%d",i,j);
return ;
}
1160
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std; int a[][];
int N; void init_(){
scanf("%d",&N);
a[][]=;
int i=,j=,cnt=;
for(int k=;k<=*N;k+=){
for(int c=;c<=k;c++) a[i][++j]=++cnt;
for(int c=;c<=k;c++) a[--i][j]=++cnt;
for(int c=;c<=k+;c++) a[i][--j]=++cnt;
for(int c=;c<=k+;c++) a[++i][j]=++cnt;
}
} int main(){
init_();
int ans=;
for(int i=-(N-)/;i<=+(N-)/;i++){
for(int j=-(N-)/;j<=+(N-)/;j++){
if(i==j||i+j==) ans+=a[i][j];
printf("%d ",a[i][j]);
}
puts("");
}
printf("%d\n",ans); return ;
}
1212
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std; int x,y; int gcd(int a,int b){
if(b==) return a;
else return gcd(b,a%b);
} int main(){
scanf("%d%d",&x,&y);
printf("%d\n",gcd(x,y));
return ;
}
1475
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define INF 0x3f3f3f3f
using namespace std; int k,ans,p;
string x; int trans(char x){
if(x>=''&&x<='') return x-'';
else return x-'A'+;
} int pow_lrb(int b,int a){
int tmp=;
while(a){
if(a&) tmp*=b;
b*=b;
a>>=;
}
return tmp;
} int main(){ cin>>x;
cin>>k;
p=x.size()-;
for(int i=;p>=;i++){
// cout<<pow_lrb(k,i)*trans(x[p])<<endl;
ans+=pow_lrb(k,i)*trans(x[p--]);
}
cout<<ans; fclose(stdin);fclose(stdout);return ;
}
1842
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std; int N; int f(int x){
if(x<) return f(x+)+f(x+)+;
else return ;
} int main(){
scanf("%d",&N);
printf("%d\n",f(N));
return ;
}
1978
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std; int f[],N; int main(){
f[]=f[]=;
for(int i=;i<=;i++) f[i]=f[i-]+f[i-]; // for(int i=1;i<=40;i++) cout<<f[i]<<" "; scanf("%d",&N);
printf("%d\n",f[N]);
return ;
}
3038
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std; int N,cnt; void f(int x){
if(cnt>=) return;
if(x==) return;
if(x&) x=*x+;
else x>>=;
++cnt;
f(x);
} int main(){
scanf("%d",&N);
while(N--){
cnt=;
int x;
scanf("%d",&x);
f(x);
if(cnt<=)printf("%d\n",cnt);
else puts("-1");
}
return ;
}
3143
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std; struct cc{int l,r;}nod[];
int N; void print_pre(int x){
printf("%d ",x);
if(nod[x].l) print_pre(nod[x].l);
if(nod[x].r) print_pre(nod[x].r);
} void print_mid(int x){
if(nod[x].l) print_mid(nod[x].l);
printf("%d ",x);
if(nod[x].r) print_mid(nod[x].r);
} void print_aft(int x){
if(nod[x].l) print_aft(nod[x].l);
if(nod[x].r) print_aft(nod[x].r);
printf("%d ",x);
} int main(){
scanf("%d",&N);
for(int i=;i<=N;i++){
scanf("%d%d",&nod[i].l,&nod[i].r);
}
print_pre();puts("");
print_mid();puts("");
print_aft();puts("");
return ;
}
//这里的题目如果你也不喜欢的话,那么也请把他们A掉吧,多花一丢丢时间而已
Lv.3 黄金
1014
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<vector>
#include<cmath>
using namespace std; int mx,V,N,a[],f[],sum; int main(){
scanf("%d%d",&V,&N);
for(int i=;i<=N;i++){
scanf("%d",&a[i]);
} f[]=; for(int i=;i<=N;i++){
for(int j=V;j>=a[i];j--){
if(f[j-a[i]]) f[j]=,mx=max(mx,j);
}
} printf("%d",V-mx); return ;
}
倒序什么的,DP竟然忘了??!!!
1044
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;
int a[],b[],k=,N,que[];
void ques1(){
for(int i=;i<=N;i++) b[i]=a[N-i+];
for(int i=;i<=N;i++)
*lower_bound(que+,que+N+,b[i])=b[i];
cout<<lower_bound(que+,que+N+,inf)-(que+)<<endl;
} void ques2(){
int cnt=N,ans=;;
for(int i=;i<=N;i++){
if(a[i]!=-){
if(cnt<=) break;
ans++;cnt--;
int x=a[i];
for(int j=i+;j<=N;j++){
if(a[j]<=x&&a[j]!=-){
x=a[j];
a[j]=-;
cnt--;
}
}
// cout<<cnt<<endl;
}
}
cout<<ans<<endl;
} int main(){
// freopen("01.in","r",stdin);
fill(que,que+,inf);
while(scanf("%d",&a[++k])==);
N=k-; ques1();
ques2(); return ;
}
不明觉厉
1098
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<vector>
#include<cmath>
using namespace std; int a[],N,aver,sum,cnt;
int main(){
freopen("01.in","r",stdin);
scanf("%d",&N);
for(int i=;i<=N;i++){
scanf("%d",&a[i]);
sum+=a[i];
}
aver=sum/N; for(int i=;i<=N;i++){
if(a[i]<aver){
int block=aver-a[i];
a[i+]-=block;
++cnt;
}
else if(a[i]>aver){
int block=a[i]-aver;
a[i+]+=block;
++cnt;
}
}
printf("%d\n",cnt);
return ;
}
1116
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<vector>
#include<cmath>
using namespace std; int N,ans,e[][];
int c[]; void dfs(int x){
if(x>N){
for(int i = ; i <= N; i++)
for(int j = ; j <= N; j++)
if(e[i][j] && (c[i] == c[j])) return ;
++ans;
return;
} //check
for(int k=;k<=;k++){
c[x]=k;
dfs(x+);
c[x]=;
}
} int main(){
scanf("%d",&N); for(int i=;i<=N;i++){
for(int j=;j<=N;j++){
scanf("%d",&e[i][j]);
}
}
dfs();
cout<<ans<<endl;
return ;
}
1219
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstdlib>
#define ll long long
using namespace std; ll f[][];
ll N,M;
ll a[]; int main(){
scanf("%lld%lld",&N,&M);
for(ll i=;i<=;i++) scanf("%lld",&a[i]); f[a[]][a[]]=;
for(ll i=;i<=;i++){
for(ll j=;j<=;j++){
if(i->&&j->)f[i][j]+=f[i-][j-];
if(i-> )f[i][j]+=f[i-][j+];
if(i->&&j->)f[i][j]+=f[i-][j-];
if(i-> )f[i][j]+=f[i-][j+];
}
} printf("%lld\n",f[a[]][a[]]); return ;
}
害怕就用long long
1220
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstdlib>
using namespace std; int a[][],f[][];
int N; int main(){ scanf("%d",&N);
for(int i=;i<=N;i++){
for(int j=;j<=i;j++){
scanf("%d",&a[i][j]);
}
} for(int i=N;i>=;i--){
for(int j=;j<=i;j++){
f[i][j]=max(f[i+][j],f[i+][j+])+a[i][j];
}
} printf("%d\n",f[][]); return ;
}
1294
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;
int a[],b[],used[],N; void f(int x,int dep){
b[dep]=x;
if(dep==N){
for(int i=;i<=N;i++){
printf("%d ",b[i]);
}
puts("");
return;
} used[x]=; for(int i=;i<=N;i++){
if(!used[i]) f(i,dep+);
} used[x]=;
} int main(){
scanf("%d",&N);
for(int i=;i<=N;i++){
f(i,);
}
return ;
}
1576
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<vector>
#include<cmath>
#define ll long long
#define INF 21474747473434
using namespace std; ll a[],N,f[];
int main(){
memset(f,,sizeof(f));
scanf("%lld",&N);
for(ll i=;i<N;i++){
scanf("%lld",&a[i]);
} for(ll i=;i<N;i++){
if(*lower_bound(f,f+N,a[i])==a[i]) continue;
*upper_bound(f,f+N,a[i])=a[i];
} ll k=lower_bound(f,f+N,INF)-f;
printf("%lld\n",k);
return ;
}
0x3f3f3f3f 不是INF 的神奇题目
3115
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstdlib>
using namespace std; char tmpa[],tmpb[];
int a[],b[],c[]; void mi(){
for(int i=;i<=max(a[],b[]);i++){
c[i]+=a[i]-b[i];
if(c[i]<){
c[i]+=;
c[i+]-=;
}
}
c[]=max(a[],b[]);
while(!c[c[]]) --c[];
} int check(){//a>b,return 1
if(a[]!=b[]){return a[]>b[];}
else{
for(int i=a[];i>=;i--){
if(a[i]<b[i]) return ;
}
} puts("");
exit();
} int main(){ scanf("%s%s",tmpa+,tmpb+);
int lena=strlen(tmpa+),lenb=strlen(tmpb+);
for(int i=lena;i>=;i--){a[i]=tmpa[lena-i+]-'';}
for(int i=lenb;i>=;i--){b[i]=tmpb[lenb-i+]-'';}
a[]=lena,b[]=lenb; // for(int i=1;i<=lena;i++) printf("%d",a[i]);
// puts("");
// for(int i=1;i<=lenb;i++) printf("%d",b[i]);
// puts(""); if(check()){//如果a>b
mi();
}
else{
swap(a,b);
printf("-");
mi();
} for(int i=c[];i>=;i--){
printf("%d",c[i]);
} return ;
}
3116
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstdlib>
using namespace std; char tmpa[],tmpb[];
int a[],b[],c[]; void pl(){
for(int i=;i<=max(a[],b[]);i++){
c[i]+=a[i]+b[i];
if(c[i]>=){
c[i]-=;
c[i+]+=;
}
}
c[]=max(a[],b[]);
if(c[c[]+]) ++c[];
} int main(){
scanf("%s%s",tmpa+,tmpb+);
int lena=strlen(tmpa+),lenb=strlen(tmpb+);
for(int i=lena;i>=;i--){a[i]=tmpa[lena-i+]-'';}
for(int i=lenb;i>=;i--){b[i]=tmpb[lenb-i+]-'';}
a[]=lena,b[]=lenb; // for(int i=1;i<=lena;i++) printf("%d",a[i]);
// puts("");
// for(int i=1;i<=lenb;i++) printf("%d",b[i]);
// puts(""); pl(); for(int i=c[];i>=;i--){
printf("%d",c[i]);
} return ;
}
//断更,做不下去了QAQ
//看了下时间,害怕