# C++題解 ## Kattis Hello World! ```cpp= #include <iostream> using namespace std; int main() { cout << "Hello World!" << "\n"; return 0; } ``` ## TOJ 519 ```cpp #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << "Do you want to say " << a << " and " << b <<" ??\n"; return 0; } ``` ## TOJ 520 ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << b << " " << a; return 0; } ``` ## Kattis Two-sum ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >>b; cout << a+b; return 0; } ``` ## Kattis Jack-O'-Lantern Juxtaposition ```cpp= #include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << a*b*c << "\n"; return 0; } ``` ## TOJ 521 ```cpp= #include <iostream> using namespace std; int main() { int m, p; cin >> m >> p; cout << m-p << "\n"; return 0; } ``` ## AtCoder A - Three Dice ```cpp= #include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << (7-a)+(7-b)+(7-c) << "\n"; return 0; } ``` ## Kattis Flatbökuveisla ```cpp= #include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; cout << n%m << "\n"; return 0; } ``` ## TOJ 522 ```cpp= #include <iostream> using namespace std; int main() { int a; cin >> a; int answer = a*a; answer = answer % 10; cout << answer << "\n"; return 0; } ``` ## TOJ 523 ```cpp= #include <iostream> using namespace std; int main() { int n; cin >> n; if (n>10) { n=n/10; } cout << n%10 << "\n"; return 0; } ``` ## Kattis Saving For Retirement ```cpp= #include <iostream> using namespace std; int main() { int b, b1, c, a, a1; //b=b現在的年齡,b1=b未來的年齡,c=b每年存的錢, //a=a現在的年齡,a1=a每年存的錢 cin >> b >> b1 >> c >> a >> a1; int d = (b1-b)*c; //d=b存錢的總量 cout << d/a1+a+1 << "\n"; return 0; } ``` ## Kattis Soylent ```cpp= #include <iostream> using namespace std; int main() { int n, a; cin >> n; for( int i=0 ; i<n ; i++ ) { cin >> a; a=(a+400-1)/400; cout << a << "\n"; } return 0; } ``` ## AtCoder A - Century ```cpp= #include <iostream> using namespace std; int main() { int a; cin >> a; cout << (a+100-1)/100 << "\n"; return 0; } ``` ## Kattis Longest Prime Sum ```cpp= #include <iostream> using namespace std; int main() { long long a; cin >> a; if (a%2>0) { a-=3; cout << a/2LL+1 << "\n"; } else { cout << a/2LL << "\n"; } return 0; } ``` ## TOJ 98 ```cpp= #include <iostream> using namespace std; int main() { long long LS; long long LM; long long LH; long long LD; long long LW; long long LY; long long L=299792458; LS=L; LM=L*60; LH=L*60*60; LD=L*60*60*24; LW=L*60*60*24*7; LY=L*60*60*24*365; cout << "1 Light-second(LS) is " << LS << " metres.\n"; cout << "1 Light-minute(LM) is " << LM << " metres.\n"; cout << "1 Light-hour(LH) is " << LH << " metres.\n"; cout << "1 Light-day(LD) is " << LD << " metres.\n"; cout << "1 Light-week(LW) is " << LW << " metres.\n"; cout << "1 Light-year(LY) is " << LY << " metres.\n"; return 0; } ``` ## TOJ 524 ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; a=(a+b)/2; b=a-b; cout << "a: " << a <<", b: " << b <<"\n"; return 0; } ``` ## TOJ 525 ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; a=(a+b)/2; cout << a <<"\n"; return 0; } ``` ## Kattis Crne ```cpp= #include <iostream> using namespace std; int main() { int a; cin >> a; if(a%2==0) { cout << (a/2LL+1)*(a/2+1) << "\n"; } else { cout << (a/2LL+1)*(a/2+2) <<"\n"; } return 0; } ``` ## TOJ 526 ```cpp= #include <iostream> using namespace std; int main() { int a=0, b=0; cin >> a; while(a) { b*=10; b+=a%10; a/=10; } cout << b << "\n"; return 0; } ``` ## TOJ 527 ```cpp= #include <iostream> using namespace std; int main() { int a; cin >> a; if(a%9!=0) { a+=9-a%9; cout << a; } else { cout << a+9; } return 0; } ``` ## Kattis Arm Coordination ```cpp= #include <iostream> using namespace std; int main() { int x, y, r; cin >> x >> y >> r; cout << x+r << " " << y+r << "\n"; cout << x+r << " " << y-r << "\n"; cout << x-r << " " << y-r << "\n"; cout << x-r << " " << y+r << "\n"; return 0; } ``` ## Kattis Making A Meowth ```cpp= #include <iostream> using namespace std; int main() { int N, P, X, Y; cin >> N >> P >> X >> Y; int page = P+P/(N-1); cout << X*P+(long long)page/N*Y << "\n"; return 0; } ``` ## TOJ 528 ```cpp= #include <iostream> using namespace std; int main() { int a; cin >> a; if(a>=0) { cout << a; } else { cout << -a; } return 0; } ``` ## TOJ 529 ```cpp= #include <iostream> using namespace std; int main() { int a, b, c; cin >> a >>b; if(a-b>=0) { c=a-b; cout << c; } else { c=b-a; cout << c; } return 0; } ``` ## TOJ 530 ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >>b; if(a>b) { cout << b << " " << a << "\n"; } else { cout << a << " " << b << "\n"; } return 0; } ``` ## TOJ 531 ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >>b; if(b>a) { cout << "true" << "\n"; } else { cout << "false" << "\n"; } return 0; } ``` ## AtCoder A-Rolling Dice ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; int ans = 0; for(int i=0;i<a;i++) { ans+=6; } if(ans>=b) { if(a<=b) { cout << "Yes" << "\n"; } else { cout << "No" << "\n"; } } else { cout << "No" << "\n"; } return 0; } ``` ## TOJ 533 ```cpp= #include <iostream> using namespace std; int main() { int a, b, n; cin >> a >> b >> n; if(a<=n && b>=n) { cout << "yes" << "\n"; } else { cout << "no" << "\n"; } return 0; } ``` ## TOJ 534 ```cpp= #include <iostream> using namespace std; int main() { int p, q; cin >> p >> q; int you = p%2; int crush = q%2; if(you==crush) { cout << "yes" << "\n"; } else { cout << "no" << "\n"; } return 0; } ``` ## AtCoder A - New Generation ABC ```cpp= #include <iostream> using namespace std; int main() { int N; cin >> N; if(N<=125) { cout << 4 << "\n"; } else if (N>=126 && N<=211) { cout << 6 << "\n"; } else { cout << 8 << "\n"; } return 0; } ``` ## TOJ 535 ```cpp= #include <iostream> using namespace std; int main() { int s; cin >> s; if(s==100) { cout << "S" << "\n"; } else if (s>=90 && s<=99) { cout << "A" << "\n"; } else if (s>=80 && s<=89) { cout << "B" << "\n"; } else if (s>=70 && s<=79) { cout << "C" << "\n"; } else if (s>=60 && s<=69) { cout << "D" << "\n"; } else { cout << "F" << "\n"; } return 0; } ``` ## AtCoder A - AtCoder Quiz 2 ```cpp= #include <iostream> using namespace std; int main() { int X; cin >> X; if(X>=90) { cout << "expert" << "\n"; } else if (X>=70 && X<90) { cout << 90-X << "\n"; } else if (X>=40 && X<70) { cout << 70-X << "\n"; } else { cout << 40-X << "\n"; } return 0; } ``` ## AtCoder A - Product ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; int ans = a*b; if(ans%2==0) { cout << "Even" << "\n"; } else { cout << "Odd" << "\n"; } return 0; } ``` ## AtCoder A-Exact Price ```cpp= #include <iostream> using namespace std; int main() { int X; cin >> X; if(X!=0 && X%100==0) { cout << "Yes" << "\n"; } else { cout << "No" << "\n"; } return 0; } ``` ## AtCoder A - Infinite Coins ```cpp= #include <iostream> using namespace std; int main() { int a, n; cin >> n >> a; int mod = n % 500; if(a>=n) { cout << "Yes" << "\n"; } else if(mod<=a) { cout << "Yes" << "\n"; } else { cout << "No" << "\n"; } return 0; } ``` ## AtCoder A - RGB Cards ```cpp= #include <iostream> using namespace std; int main() { int r, g, b; cin >> r >> g >> b; int number = r*100 + g*10 + b; if(number%4==0) { cout << "YES" << "\n"; } else { cout << "NO" << "\n"; } return 0; } ``` ## Kattis Sandy ```cpp= #include <iostream> using namespace std; int main() { int b, l; cin >> b >> l; if(b>l) { cout << l*2 << "\n"; } else if (b<l) { cout << b*2 << "\n"; } else { cout << b*2 << "\n"; } return 0; } ``` ## AtCoder A - Counting ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; if(a<b) { cout << b-a+1 << "\n"; } else { cout << 0 << "\n"; } return 0; } ``` ## AtCoder A - Cabbages ```cpp= #include <iostream> using namespace std; int main() { int n, a, x, y; cin >> n >> a >> x >> y; if(n<=a) { cout << n*x << "\n"; } else { cout << (n-a)*y+a*x << "\n"; } return 0; } ``` ## AtCoder B - Two Switches ```cpp= #include <iostream> using namespace std; int main() { int minA, maxB, minC, maxD, min, max; cin >> minA >> maxB >> minC >> maxD; if(minA>minC) { min=minA; } else { min=minC; } if(maxB<maxD) { max=maxB; } else { max=maxD; } if(max>=min) { cout << max-min << "\n"; } else { cout << 0 << "\n"; } return 0; } ``` ## AtCoder A - Alloy ```cpp= #include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; if(a==0 && b>0) { cout << "Silver" << "\n"; } else if(a>0 && b==0) { cout << "Gold" << "\n"; } else { cout << "Alloy" << "\n"; } return 0; } ``` ## AtCoder A - うるう年 ```cpp= #include <iostream> using namespace std; int main() { int a; cin >> a; if(a%4==0) { if(a%400==0 || a%100!=0) { cout << "YES" << "\n"; } else { cout << "NO" << "\n"; } } else { cout << "NO" << "\n"; } return 0; } ``` ## AtCoder A - Placing Marbles ```cpp= #include <iostream> using namespace std; int main() { string e; cin >> e; int a = 0; for (char c : e) { if (c == '1') { a++; } } cout << a << "\n"; return 0; } ``` ## TOJ 532 ```cpp= #include <iostream> using namespace std; int main() { int p, q; int p2=0; int p3=0; int q2=0; int q3=0; cin >> p >> q; if(p%2==0) { p2 =1; } if(q%2==0) { q2 = 1; } if(p%3==0) { p3 = 1; } if(q%3==0) { q3 = 1; } cout << p2+q2 << " " << p3+q3 << "\n"; return 0; } ``` ## Kattis doublepassword ```cpp= #include <iostream> using namespace std; int main() { string password1, password2; cin >> password1 >> password2; int result=1; for(int i=0; i<4; i++) { if(password1[i]==password2[i]) { result*=1; } else { result*=2; } } cout << result << "\n"; return 0; } ``` ## TOJ 94 ```cpp= #include <iostream> using namespace std; int main() { int a; cin >> a; if(a>=3 && a<=5) { cout << "Spring!" << "\n"; } else if(a>=6 && a<=8) { cout << "Summer!" << "\n"; } else if(a>=9 && a<=11) { cout << "Autumn!" << "\n"; } else { cout << "Winter!" << "\n"; } return 0; } ``` ## Kattis Quadrant Selection ```cpp= #include <iostream> using namespace std; int main() { int x, y; cin >> x >> y; if(x>0 && y>0) { cout << 1 << "\n"; } else if(x<0 && y>0) { cout << 2 << "\n"; } else if(x<0 && y<0) { cout << 3 << "\n"; } else { cout << 4 << "\n"; } return 0; } ``` ## Kattis Distributing Poffins ```cpp= #include <iostream> using namespace std; int main() { int n, p; cin >> n >> p; if(p%n==0) { cout << 0 << "\n"; } else { cout << 1 << "\n"; } return 0; } ``` ## AtCoder A - Repression ```cpp= #include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int max1, max2; if(a<b) { swap(a, b); } if(b<c) { swap(b, c); } if(a<b) { swap(a, b); } max1=a; max2=b; cout << a+b << "\n"; return 0; } ``` ## TOJ 537 ```cpp= #include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int max1, max2; if(a<b) { swap(a, b); } if(b<c) { swap(b, c); } if(a<b) { swap(a, b); } max1=a; max2=b; if(b+c>a) { cout << "yes" << "\n"; } else { cout << "no" << "\n"; } return 0; } ``` ## TOJ 515 ```cpp= #include <iostream> using namespace std; int main() { string s; cin >> s; if(s.size()==4 && s[0]==s[1] && s[1]==s[2] && s[2]==s[3]) { cout << "GREAT!!" << "\n"; } else { cout << "OAQ" << "\n"; } return 0; } ``` ## Kattis FYI ```cpp= #include <iostream> using namespace std; int main() { int e; cin >> e; if(e/10000==555) { cout << 1 << "\n"; } else { cout << 0 << "\n"; } return 0; } ``` ## Zero Judge c294. APCS-2016-1029-1三角形辨別 ```cpp= #include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if(a>b) { swap(a, b); } if(b>c) { swap(b, c); } if(a>b) { swap(a, b); } if(a+b <= c) { cout << a << " " << b << " " << c << "\n"; cout << "No" << "\n"; } else if (a*a+b*b<c*c) { cout << a << " " << b << " " << c << "\n"; cout << "Obtuse" << "\n"; } else if (a*a+b*b==c*c) { cout << a << " " << b << " " << c << "\n"; cout << "Right" << "\n"; } else { cout << a << " " << b << " " << c << "\n"; cout << "Acute" << "\n"; } return 0; } ``` ## Kattis Cetvrta ```cpp= #include <iostream> using namespace std; int main() { int x1, y1, x2, y2, x3, y3, x4, y4; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; if(x1==x2) { x4=x3; } else if(x2==x3) { x4=x1; } else { x4=x2; } if(y1==y2) { y4=y3; } else if(y2==y3) { y4=y1; } else { y4=y2; } cout << x4 << " " << y4 << "\n"; return 0; } ``` ## TOJ 536 ```cpp= #include <iostream> using namespace std; int main() { int s1, s2, b1, b2; cin >> s1 >> s2 >> b1 >> b2; if((s1<=b1 && s2>=b1) || (s1<=b2 && s2>=b2) || (s1>=b1 && s2<=b2)) { cout << "yes" << "\n"; } else { cout << "no" << "\n"; } return 0; } ``` ## Kattis Stuck In A Time Loop ```cpp= #include <iostream> using namespace std; int main() { int n; cin >> n; for(int i=1 ; i<=n ; i++) { cout << i << " Abracadabra" << "\n"; } return 0; } ``` ## TOJ 578 ```cpp= #include <iostream> using namespace std; int main() { int n; cin >> n; n=n-1; for(int i=1 ; i<=n ; i++) { cout << i << "\n"; i++; } return 0; } ``` ## Kattis Thanos ```cpp= include <iostream> using namespace std; int main() { int t; cin >> t; while(t--) { long long p, r, f; cin >> p >> r >> f; int y=0; while(p<=f) { y++; p*=r; } cout << y << "\n"; } return 0; } ``` ## TOJ 576 ```cpp= #include <iostream> using namespace std; int main() { int n, t=1; cin >> n; while(n/10) { t++; n/=10; } cout << t << "\n"; return 0; } ``` ## Kattis Building Pyramids ```cpp= #include <iostream> using namespace std; int main() { int n, total, w=1, h=0; cin >> n; for(total=0 ; total<=n-w*w ; w+=2) { total+=w*w; h++; } cout << h << "\n"; } ``` ## Kattis Cinema Crowds 2 ```cpp= #include <iostream> using namespace std; int main() { int a, n; cin >> a >> n; int g; g=n; for(int i=0; i<n; i++) { int p; cin >> p; if(a-p<0) { cout << g << "\n"; break; } a-=p; g-=1; } return 0; } ``` ## Kattis Oddities ```cpp= #include<iostream> using namespace std; int main() { int times; cin >> times; for(int i=0; i<times; i++) { int x; cin >> x; if(x%2==0) { cout << x << " is even" << "\n"; } else { cout << x << " is odd" << "\n"; } } return 0; } ``` ## Kattis FizzBuzz ```cpp= #include <iostream> using namespace std; int main() { int x, y, n; cin >> x >> y >> n; int b=0; for(int i=0; i<n; i++) { b+=1; if(b%x==0 && b%y!=0) { cout << "Fizz" << "\n"; } else if(b%x!=0 && b%y==0) { cout << "Buzz" << "\n"; } else if(b%x==0 && b%y==0) { cout << "FizzBuzz" << "\n"; } else { cout << b << "\n"; } } return 0; } ``` ## Kattis Cinema Crowds ```cpp= #include <iostream> using namespace std; int main() { int a, n; cin >> a >> n; int g=0; for(int i=0; i<n; i++) { int p; cin >> p; if(a>=p) { a-=p; } else { g++; } } cout << g << "\n"; return 0; } ``` ## Kattis Jumbo Javelin ```cpp= #include<iostream> using namespace std; int main() { int times, t, l; t=0; cin >> times; for(int i=0; i<times; i++) { cin >> l; t+=l; } cout << t-times+1 << "\n"; return 0; } ``` ## TOJ 577 ```cpp= #include<iostream> using namespace std; int main() { long long times, a, b, t; cin >> times; for(int i=0; i<times; i++) { t=1; cin >> a >> b; for(int n=0; n<b; n++) { t*=a; } cout << t << "\n"; } return 0; } ``` ## AtCoder B - Failing Grade ```cpp= #include<iostream> using namespace std; int main() { int n; cin >> n; int p; cin >> p; int f=0; for(int i=0; i<n; i++) { int grade; cin >> grade; if(grade<p) { f++; } } cout << f << "\n"; return 0; } ``` ## Kattis Job Expenses ```cpp= #include <iostream> using namespace std; int main() { int n; cin >> n; int total=0; for(int i=0; i<n; i++) { int a; cin >> a; if(a<0) { total-=a; } } cout << total << "\n"; return 0; } ``` ## Kattis Plants vs Bad Guys ```cpp= #include <iostream> using namespace std; int main() { long long n; cin >> n; long long min=9223372036854775807; long a; for(int i=0; i<n; i++) { cin >> a; if(a<min) { min=a; } } cout << min+1 << "\n"; return 0; } ``` ## Kattis Stopwatch ```cpp= #include<iostream> using namespace std; int main() { int n; cin >> n; int total=0; int last=0; bool running=false; for(int i=0; i<n; i++) { int now; cin >> now; if(running) { total+=(now-last); } last=now; running=!running; } if(running) { cout << "still running" << "\n"; } else { cout << total << "\n"; } return 0; } ``` ## TOJ 104 ```cpp= #include <iostream> using namespace std; int main() { int n; cin >> n; for(int i=0; i<n; i++) { for(int j=0; j<n-1-i; j++) { cout << " "; } for(int g=0; g<2*(i+1)-1; g++) { cout << "*"; } cout << "\n"; } return 0; } ``` ## Kattis Pet ```cpp= #include <iostream> using namespace std; int main() { int max=0; int winner=0; int total; int a, b, c, d; for(int i=1; i<=5; i++) { total=0; for(int j=0; j<4; j++) { int grade; cin >> grade; total+=grade; } if(total>max) { max=total; winner=i; } } cout << winner << " " << max << "\n"; return 0; } ``` ## TOJ 494 ```cpp= #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; for(int r=0; r<n*k; r++) { for(int c=0; c<n*k; c++) { if(((r/k)+(c/k))%2==0) { cout << "*"; } else { cout << " "; } } cout << "\n"; } return 0; } ``` ## Kattis Öfugsnúið ```cpp= #include <iostream> using namespace std; int main () { int n; cin >> n; int number[n]; for(int i=0; i<n; i++) { cin >> number[i]; } for(int i=n-1; i>=0; i--) { cout << number[i] << "\n"; } return 0; } ``` ## AtCoder B - Maximum Difference ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { int n; cin >> n; int a[n]; for(int i=0; i<n; i++) { cin >> a[i]; } int min=*min_element(a, a+n); int max=*max_element(a, a+n); cout << max-min << "\n"; return 0; } ``` ## Kattis stafur ```cpp= #include <iostream> using namespace std; int main () { char n; cin >> n; if(n=='A') { cout << "Jebb" << "\n"; } else if(n=='E') { cout << "Jebb" << "\n"; } else if(n=='I') { cout << "Jebb" << "\n"; } else if(n=='O') { cout << "Jebb" << "\n"; } else if(n=='U') { cout << "Jebb" << "\n"; } else if (n=='Y') { cout << "Kannski" << "\n"; } else { cout << "Neibb" << "\n"; } return 0; } ``` ## AtCoder A - Something on It ```cpp= #include <iostream> #include <algorithm> using namespace std; int r(string s) { int b=700; int t=count(s.begin(), s.end(), 'o')*100; return b+t; } int main() { string s; cin >> s; cout << r(s) << "\n"; return 0; } ``` ## TOJ 100 ```cpp= #include <iostream> using namespace std; int main () { char n; cin >> n; cout << (char)(n-1) << "\n"; return 0; } ``` ## TOJ 101 ```cpp= #include <iostream> using namespace std; int main () { int n; cin >> n; cout << (char)(n+64) << "\n"; return 0; } ``` ## TOJ 244 ```cpp= #include <iostream> using namespace std; int main() { string s; int n; cin >> n >> s; for(int i=0; i<s.size(); i++) { if(s[i]<='Z') { cout << (char)(s[i]-'A'+'a'); } else { cout << (char)(s[i]-'a'+'A'); } } cout << "\n"; return 0; } ``` ## TOJ 92 ```cpp= #include <iostream> using namespace std; int main() { string a; string b; string c; cin >> a >> b >> c; cout << "Hello, " << a << ", " << b << ", and " << c << "!" << "\n"; return 0; } ``` ## TOJ 5 ```cpp= #include <iostream> using namespace std; int main() { string n; getline(cin,n); cout << "Hello ," << n << " !" << "\n"; return 0; } ``` ## Kattis B - Maritozzo ```cpp= #include <iostream> using namespace std; int main() { string s1, s2, s3, t; cin >> s1 >> s2 >> s3 >> t; for(char c:t) { if(c=='1') { cout << s1; } else if(c=='2') { cout << s2; } else { cout << s3; } } cout << "\n"; return 0; } ``` ## AtCoder A - Your First Judge ```cpp= #include <iostream> using namespace std; int main() { string s; cin >> s; if(s=="Hello,World!") { cout << "AC" << "\n"; } else { cout << "WA" << "\n"; } return 0; } ``` ## TOJ 103 ```cpp= #include <iostream> using namespace std; int main() { string t1, t2, s1, s2; cin >> t1 >> s1 >> t2 >> s2; if(t1==t2 && s1==s2) { cout << "GOOD" << "\n"; } else if (t1!=t2 && s1!=s2) { cout << "OTZ" << "\n"; } else { cout << "=~=" << "\n"; } return 0; } ``` ## CSES Repetitions ```cpp= #include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int m=1, n=1; for(int i=1; i<s.length(); i++) { if(s[i]==s[i-1]) { n++; } else { n=1; } m=max(m, n); } cout << m << "\n"; return 0; } ``` ## AtCoder A - Blood Pressure ```cpp= #include <iostream> using namespace std; int main() { double a, b; cin >> a >> b; cout << (a-b)/3+b << "\n"; return 0; } ``` ## Kattis Triangle Area ```cpp= #include <iostream> using namespace std; int main() { double a, b; cin >> a >> b; cout << a*b/2 << "\n"; return 0; } ``` ## AtCoder A - kcal ```cpp= #include <iostream> using namespace std; int main() { double a, b; cin >> a >> b; cout << a*(b/100) << "\n"; return 0; } ``` ## Kattis Rectangle Area ```cpp= #include <iostream> using namespace std; int main() { double x1, y1, x2, y2, l, w; cin >> x1 >> y1 >> x2 >> y2; l=x2-x1; w=y2-y1; if(l<0) { l=0-l; } if(w<0) { w=0-w; } cout << l*w << "\n"; return 0; } ``` ## Kattis Three in a Row ```cpp= #include <iostream> using namespace std; int main() { long long count=0; long long n; cin >> n; for(long long i=1; i*(i+1)*(i+2)<n; i++) { count++; } cout << count << "\n"; return 0; } ``` ## AtCoder C - Otoshidama 待補 ## AtCoder C - Ringo's Favorite Numbers 2 ```cpp= #include <iostream> #include <vector> using namespace std; int main() { vector<long long> rm(200, 0); long long count=0; int r, num; int n; cin >> n; for(int i=0; i<n; i++) { cin >> num; int r=num%200; count+=rm[r]; rm[r]++; } cout << count << "\n"; return 0; } ``` ## AtCoder C - Long Sequence ```cpp= #include <iostream> #include <vector> using namespace std; int main() { long long n, x; cin >> n; vector <long long> a(n); long long sumA=0; for(long long i=0; i<n; i++) { cin >> a[i]; sumA+=a[i]; } cin >> x; long long count=(x/sumA)*n; long long sum=(x/sumA)*sumA; for(long long i=0; i<n; i++) { sum+=a[i]; count++; if(sum>x) { break; } } cout << count << "\n"; return 0; } ``` ## Atcoder B - Training Camp ```cpp= #include <iostream> using namespace std; int main() { const int mod=1e9+7; long long n, t; t=1; cin >> n; for(long long i=1; i<=n; i++) { t=(t*i)%mod; } cout << t << "\n"; return 0; } ``` ## Kattis Breaking Branches ```cpp= #include <iostream> using namespace std; int main() { int a; cin >> a; if(a%2==0) { cout << "Alice" << "\n"; cout << a/2; } else { cout << "Bob" << "\n"; } return 0; } ```