Editorial for Ăn khoai
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Lưu ý: Các code mẫu dưới đây chỉ mang tính tham khảo và có thể không AC được bài tập này
Code mẫu của flashmt
#include<iostream> #include<string> using namespace std; int main() { string s; int n; while (1) { cin >> s; if (s=="[END]") return 0; if (s=="[CASE]") { cin >> n; if ((n%5==0)||(n%5==2)) cout << "Hanako" << endl; else cout << "Taro" << endl; } } return 0; }
Code mẫu của happyboy99x
#include<cstdio> int main() { int n; while(scanf("%*s%d", &n) != EOF) printf(n % 5 == 0 || n % 5 == 2 ? "Hanako\n" : "Taro\n"); return 0; }
Code mẫu của ladpro98
const f:array[0..4] of string = ('Hanako','Taro','Hanako','Taro','Taro'); var n:longint; s:string; inp:text; begin assign(inp,'');reset(inp); while not eof(inp) do begin readln(inp,s); if s='[END]' then exit; readln(inp,n);readln(inp); n:=n mod 5; writeln(f[n]); end; end.
Code mẫu của hieult
#include <stdio.h> //#include <conio.h> int main() { //freopen("POTATO.inp","r",stdin); int n; char s[10]; while(gets(s)) { if(s[0]!='[') continue; else if(s[1]=='E') break; else { scanf("%d",&n); if(n%5==0||n%5==2) printf("Hanako\n"); else printf("Taro\n"); } } //getch(); }
Code mẫu của ll931110
#include <iostream> #include <string> using namespace std; int main() { string s; while (1) { cin >> s; if (s == "[END]") break; int n; cin >> n; if (n % 5 == 2 || n % 5 == 0) cout << "Hanako"; else cout << "Taro"; cout << endl; }; };
Code mẫu của khuc_tuan
while True: s = raw_input().split(chr(13))[0] if s == "[END]": break n = int(raw_input().split(chr(13))[0]) raw_input() if (n%5==0) or (n%5==2): print "Hanako" else: print "Taro"
Comments