辽宁师范大学 • 张大为@https://daweizh.github.io/noip/
#include <iostream> using namespace std; int main(){ int n; cin >> n; string s = "positive"; if (n ==0) s = "zero"; else if (n<0) s = "negative"; cout << s << endl; return 0; }
#include <iostream> using namespace std; int main(){ double n; cin >> n; if (n<0) n = -n; printf("%.2f",n); return 0; }
#include <iostream> using namespace std; int main(){ int n; cin >> n; string s = "even"; if (n%2==1) s = "odd"; cout << s << endl; return 0; }
#include <iostream> using namespace std; int main(){ char c=getchar(); string s = "NO"; if (c%2==1) s = "YES"; cout << s << endl; return 0; }
#include <iostream> using namespace std; int main(){ int x,y; cin >> x >> y; string s = ">"; if (x==y) s = "="; else if (x <y) s = "<"; cout << s << endl; return 0; }
#include <iostream> using namespace std; int main(){ int i; cin >> i; if (i>=10 && i<=99) i = 1; else i = 0; cout << i << endl; return 0; }
#include <iostream> using namespace std; int main(){ int x,y,z; cin >> x >> y; if (x>=10 || y >= 20) z = 1; else z = 0; cout << z << endl; return 0; }
#include <iostream> using namespace std; int main(){ int n; cin >> n; string s = "NO"; if (n % 3==0 && n % 5==0) s = "YES"; cout << s << endl; return 0; }
#include <iostream> using namespace std; int main(){ int a; cin >> a ; if(a%3==0 && a%5==0 && a%7==0){ cout << 3 << " " << 5 << " " << 7 << endl; }else if(a%3==0 && a%5==0){ cout << 3 << " " << 5 << endl; }else if(a%5==0 && a%7==0){ cout << 5 << " " << 7 << endl; }else if(a%3==0 && a%7==0){ cout << 3 << " " << 7 << endl; }else if(a%3==0){ cout << 3 << endl; }else if(a%5==0){ cout << 5 << endl; }else if(a%7==0){ cout << 7 << endl; }else{ cout << "n" << endl; } return 0; }
#include <iostream> using namespace std; int main(){ int c1,c2; cin >> c1 >> c2; string s = "0"; if ((c1<60 && c2>=60 )|| (c1>=60 && c2 <60)) s = "1"; cout << s << endl; return 0; }
#include <iostream> using namespace std; int main(){ int d; cin >> d; string s = "YES"; if (d==1 || d==3 || d == 5 ) s = "NO"; cout << s << endl; return 0; }
#include <iostream> using namespace std; int main(){ double m; cin >> m; string s = "All"; double bikeTime = m / 3.0 + 50; double walkTime = m / 1.2; if ( bikeTime < walkTime ) s = "Bike"; else if (bikeTime > walkTime) s = "Walk"; cout << s << endl; return 0; }
#include <iostream> using namespace std; int main(){ double n,f=0; cin >> n; if ( n>=0 && n < 5 ) f = -n + 2.5; else if (n>=5 && n<10) f = 2 -1.5*(n-3)*(n-3); else if (n>=10 && n<20) f = n / 2 - 1.5; printf("%.3f",f); return 0; }
#include <iostream> #include <cmath> using namespace std; int main(){ double w; char c; int f; cin >> w >> c; if (w <= 1000) f = 8; else f = ceil((w-1000)/500)*4 + 8; if (c=='y') f = f + 5; printf("%d",f); return 0; }
#include <iostream> using namespace std; int main(){ int a,b,c; cin >> a >> b >> c; if(a>b && b>c){ cout << a << endl; }else if(b>c){ cout << b << endl; }else{ cout << c << endl; } return 0; }
#include <iostream> using namespace std; int main(){ int x,y,z; cin >> x >> y >>z; string s = "yes"; if (x + y <= z) s = "no"; else if(x + z <= y) s = "no"; else if(y + z <= x) s = "no"; cout << s << endl; return 0; }
#include <iostream> using namespace std; int main(){ int y; cin >> y; string s = "N"; if (y % 4 ==0 && !(y % 100==0 && y % 400 !=0) && !(y%3200==0)) s = "Y"; cout << s << endl; return 0; }
#include <iostream> using namespace std; int main(){ int x,y; cin >>x >> y; string s = "no"; if (x<=1 && x>=-1 && y <=1 && y>=-1) s = "yes"; cout << s << endl; return 0; }
#include <iostream> using namespace std; int main(){ int x,y; char c; int result = 0; string s = ""; cin >>x >> y >> c; switch(c){ case '+': result = x + y; break; case '-': result = x - y; break; case '*': result = x * y; break; case '/': if (y==0) s = "Divided by zero!"; else result = x / y; break; default: s = "Invalid operator!"; } if (s=="") cout << result << endl; else cout << s << endl; return 0; }
#include <iostream> #include <cmath> using namespace std; int main(){ double a,b,c; cin >> a >> b >> c; double b2 = b * b; double dt = 4 * a * c; double a2 = 2 * a; if (b2 < dt){ double r = -b / a2; if (b==0){ r = 0; } double v = sqrt(dt-b2)/a2; printf("x1=%.5f+%.5fi;x2=%.5f-%.5fi",r,v,r,v); }else{ double x1 = (-b + sqrt(b2-dt))/a2; double x2 = (-b - sqrt(b2-dt))/a2; if (b2>dt){ printf("x1=%.5f;x2=%.5f",x1,x2); }else{ printf("x1=x2=%.5f",x1); } } return 0; }
#include <iostream> using namespace std; int main(){ int n; //苹果数量 int x; //虫子吃一个苹果花的时间 int y; //虫子吃了多少时间的苹果 cin >> n>> x >>y; //分别输入苹果个数,虫子吃一个苹果的时间,虫子吃了多长时间的苹果 if(n>0){ //如果箱子里有苹果 if(x>0){ if(y>0){ int m = y/x; //计算吃了几个整苹果 if(y%x!=0) m = m + 1; if(n-m>0) cout << n-m << endl; else cout << "0" << endl; }else{ cout << n << endl; } }else{ cout << n << endl; } }else{ //否则,箱子里没有苹果 cout << "0" << endl; } return 0; }