辽宁师范大学 • 张大为@https://daweizh.github.io/noip/
#include <iostream> using namespace std; int main(){ int n,a; double sum = 0; cin >> n; for (int i=0;i<n;i++){ cin >> a; sum = sum + a; } printf("%.2f",sum/n); }
#include <iostream> using namespace std; int main(){ double a; double sum = 0; for (int i=0;i<12;i++){ cin >> a; sum = sum + a; } printf("$%.2f",sum/12); }
#include <iostream> using namespace std; int main(){ int n; double a; double sum = 0; cin >> n; for (int i=0;i<n;i++){ cin >> a; sum = sum + a; } printf("%.4f",sum/n); }
#include <iostream> using namespace std; int main(){ int n,a,sum = 0; cin >> n; for (int i=0;i<n;i++){ cin >> a; sum = sum + a; } printf("%d %.5f",sum,(double)sum/n); return 0; }
#include <iostream> using namespace std; int main(){ int n,a,max = 0; cin >> n; for (int i=0;i<n;i++){ cin >> a; if (a>max){ max = a; } } printf("%d",max); return 0; }
#include <iostream> using namespace std; int main(){ int n,a,max = 0,min=10000; cin >> n; for (int i=0;i<n;i++){ cin >> a; if (a>max){ max = a; } if(a<min){ min = a; } } printf("%d",max-min); return 0; }
#include <iostream> using namespace std; int main(){ int n,g,s,c,sg=0,ss=0,sc=0; cin >> n; for (int i=0;i<n;i++){ cin >> g >> s >> c; sg = sg + g; ss = ss + s; sc = sc + c; } printf("%d %d %d %d",sg,ss,sc,sg+ss+sc); return 0; }
#include <iostream> using namespace std; int main(){ int n,a,sum=0; cin >> n; for (int i=1;i<n;i++){ cin >> a; sum = sum + a; } printf("%d",(n-2)*180-sum); return 0; }
#include <iostream> using namespace std; int main(){ int m,n; int sum = 0; cin >> m >> n; for(int i=m;i<=n;i++){ if(i%2==1){ sum = sum + i; } } cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main(){ int m,n,sum=0; cin >> m >> n; for (int i=m;i<=n;i++){ if(i%17==0){ sum = sum + i; } } printf("%d",sum); return 0; }
#include <iostream> using namespace std; int main(){ int n,a,s1=0,s5=0,s10=0; cin >> n; for (int i=0;i<n;i++){ cin >> a; if(a==1){ s1 = s1 + 1; } if(a==5){ s5 = s5 + 1; } if(a==10){ s10 = s10 + 1; } } cout << s1 << endl; cout << s5 << endl; cout << s10 << endl; return 0; }
#include <iostream> using namespace std; int main(){ int N,m,a,sum=0; cin >> N >> m; for (int i=0;i<N;i++){ cin >> a; if(a==m){ sum = sum + 1; } } cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main(){ int a,n,mul=1; cin >> a >> n; for(int i=0;i<n;i++){ mul = mul * a; } cout << mul << endl; return 0; }
#include <iostream> #include <cmath> using namespace std; int main(){ double x,n; cin >> x >> n; printf("%.4f",x*pow((1+0.001),n)); return 0; }
#include <iostream> using namespace std; int main(){ double R,M,Y; cin >> R >> M >> Y; for (int i=0;i<Y;i++){ M = M * (1 + R/100); } printf("%d",(int)M); return 0; }
#include <iostream> using namespace std; int main(){ double sumn,hp=200,n,k; int m=1; cin >> n >> k; sumn = n; while(sumn<hp && m <40){ sumn = sumn + n; hp = hp * (1+k/100); m = m + 1; } if(m<=20) cout << m << endl; else cout << "Impossible" << endl; return 0; }
#include <iostream> using namespace std; int main(){ int k,first=1,second=1,fb; cin >> k; if (k > 2) for (int i=3;i<=k;i++){ fb = first + second; first = second; second = fb; } else fb = 1; cout << fb << endl; return 0; }
#include <iostream> using namespace std; int main(){ int n; double a[20][2]; cin >> n; for (int i=0;i<n;i++){ cin >> a[i][1] >> a[i][2]; } double x = a[0][2] / a[0][1] * 100; for(int i=1;i<n;i++){ double y = a[i][2] / a[i][1] * 100; if (y-x>5) { cout << "better" << endl; }else if (x-y>5){ cout << "worse" << endl; }else{ cout << "same" << endl; } } return 0; }
#include <iostream> #include <cmath> using namespace std; int main(){ int n; double a,b,c,t=0; cin >> n; for(int i=0;i<n;i++){ cin >> a >> b >> c; t = t + sqrt(a*a+b*b) * 2 / 50 + 1.5 * c; } printf("%.0f",ceil(t)); return 0; }
#include <iostream> using namespace std; int main(){ double h,sum=0; cin >> h; sum = h; for(int i=1;i<10;i++){ sum = sum + h; h = h / 2; } cout << sum << endl; cout << h/2 << endl; return 0; }
#include <iostream> using namespace std; int main(){ long long int N; cin >> N; while(N>1){ if(N%2==1){ cout << N << "*3+1=" << N * 3 + 1 << endl; N = N * 3 + 1; }else{ cout << N << "/2=" << N / 2 << endl; N = N / 2; } } cout << "End"; return 0; }
#include <iostream> using namespace std; int main(){ long p,a,r =0,sum=0; for(int i=0;i<12;i++){ r = r + 300; cin >> p; r = r - p; a = r/100; sum = sum + a * 100; r = r - a * 100; if (r<0){ cout << "-" << i+1 << endl; break; } } if (r>0) cout << sum * 1.2 + r << endl; return 0; }
#include <iostream> using namespace std; int main(){ long m,n,a,sum=0; cin >> m >>n; for(int i=0;i<n;i++){ cin >> a; if (m -a >= 0) m = m - a; else sum = sum + 1; } cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main(){ long n,a,b,sum=0,max=0; cin >> n; for(int i=0;i<n;i++){ cin >> a >> b; if (a>=90 && a<=140 && b >=60 && b <=90){ sum = sum + 1; }else{ if (sum > max) max = sum; sum = 0; } } if (sum > max) max = sum; cout << max << endl; return 0; }
#include <iostream> using namespace std; int main(){ int i,j,k; bool flag = false; for(i=0;i<7;i++){ for(j=0;j<7;j++){ for(k=0;k<7;k++){ if (i*9*9+j*9+k==i+j*7+k*7*7 && (i!=0 || j!=0 || k!=0)){ cout << i*9*9+j*9+k << endl; cout << k << j << i << endl; cout << i << j << k << endl; } } } } return 0; }
#include <iostream> using namespace std; int main(){ int n,a,sum=0; int first,second,third,forth; cin >> n; for(int i=0;i<n;i++){ cin >> a; forth = a % 10; third = (a - forth)/10 % 10; second = (a-forth - third * 10)/100 % 10; first = (a - forth - third*10 - second * 100)/1000; if (forth - first - second - third > 0){ sum = sum + 1; } } cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main(){ long K,n=0; double sn = 0; cin >> K; while(sn<=K){ n = n + 1; sn = sn + 1.0d/n; } cout << n << endl; return 0; }
#include <iostream> using namespace std; int main(){ long long int n,r; cin >> n; while(n>0){ r = n % 10; cout << r; n = (n - r)/10; if (n>0){ cout << " "; } } cout << endl; return 0; }
#include <iostream> using namespace std; int main(){ long long int n,i=0; cin >> n; while(n!=0){ i = i*10 + n % 10; n = n / 10; } printf("%d",i); return 0; }
#include <iostream> using namespace std; int main(){ long m,k,sum=0; cin >> m >> k; if (m % 19 ==0){ while(m!=0){ if (m % 10==3){ sum = sum + 1; } m = m / 10; } if (sum==k) cout << "YES" << endl; else cout << "NO" << endl; }else cout << "NO" << endl; return 0; }
#include <iostream> using namespace std; int main(){ long N,M; bool light = true; cin >> N >> M; cout << 1 ; for(int i=2;i<=N;i++){ light = true; for(int j=1;j<=M;j++){ if(i%j==0){ light = ! light; } } if(!light) cout << "," << i; } return 0; }
#include <iostream> using namespace std; int main(){ int n; double p=1,q=2,sum = 0,temp; cin >> n; for (int i=0;i<n;i++){ sum = sum + q / p; temp = q; q = q + p; p = temp; } printf("%.4f",sum); return 0; }
#include <iostream> using namespace std; int main(){ int n; double sum = 0; cin >> n; for (int i=1;i<=n;i++){ if(i%2==1) sum = sum + 1.0d/i; else sum = sum - 1.0d/i; } printf("%.4f",sum); return 0; }
#include <iostream> using namespace std; int main(){ int n; long long int sum = 0,product=1; cin >> n; for (int i=1;i<=n;i++){ product = 1; for(int j=1;j<=i;j++){ product = product * j; } sum = sum + product; } cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main(){ int n; double e = 1,p; cin >> n; for (int i=1;i<=n;i++){ p = 1; for(int j=1;j<=i;j++){ p = p * j; } e = e + 1/p; } printf("%.10f",e); }
#include <iostream> #include <cmath> using namespace std; int main(){ long int n; double x,f = 1,p; cin >> x >> n ; f = f + x; for (int i=2;i<=n;i++){ f = f + pow(x,i); } printf("%.2f",f); }
#include <iostream> using namespace std; int main(){ int M,N,X; cin >> M >> N >> X ; while(N <=M && X * N >=M){ if (M%N==0){ X = X - M / N; } else { X = X - M / N -1; } N = N + M/N; } printf("%d",N); return 0; }
#include <iostream> using namespace std; int main(){ int n,c[100]; cin >> n ; for(int i=n;i>=0;i--){ cin >> c[i]; c[i] = c[i] * i; } cout << c[n]; for(int i=n-1;i>0;i--){ cout << " " << c[i]; } cout << endl; return 0; }
#include <iostream> using namespace std; int main(){ int n,sum=0,a; cin >> n ; for(int i=1;i<=n;i++){ if(i%7!=0){ a = i; while(a>0){ if (a % 10 == 7){ break; } a = a / 10; } if (a ==0){ sum = sum + i * i; } } } cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main(){ int n,sum=0,a; cin >> n ; for(int i=1;i<=n;i++){ a = i; while(a>0){ if (a % 10 == 1){ sum = sum + 1; } a = a / 10; } } cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main(){ int L,R,sum=0,a; cin >> L >> R ; for(int i=L;i<=R;i++){ a = i; while(a>0){ if (a % 10 == 2){ sum = sum + 1; } a = a / 10; } } cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main(){ int h,w,fill; char c; cin >> h >> w >> c >> fill ; for (int i=0;i<w;i++) cout << c; cout << endl; for (int i=0;i<h-2;i++){ cout << c; for(int j=0;j<w-2;j++) if (fill==0) cout << " "; else cout << c; cout << c << endl; } for (int i=0;i<w;i++) cout << c; cout << endl; return 0; }
#include <iostream> using namespace std; int main(){ long long int n,j,t; cin >> n ; for (int i=2;i*i<n;i++){ if(n % i ==0 ){ cout << n / i << endl; break; } } return 0; }
#include <iostream> #include <cmath> using namespace std; int main(){ long n,c=2,i=3,j; bool flag = false; cin >> n ; if (n==1) i = 2; else while(c<n){ i = i + 2; flag = true; for(j=2;j<=sqrt(i);j++) if (i % j==0){ flag = false; break; } if(flag){ c = c + 1; } } cout << i << endl; return 0; }
#include <iostream> using namespace std; int main(){ long n,coin=1,sum=0; cin >> n ; int count = 1; while(count <= n){ for(int j=1;j<=coin&&count <=n;j++){ sum = sum + coin; count = count + 1; } coin = coin + 1; } cout << sum << endl; return 0; }