range(1, 10): for j in range(1, 10): if i * j == n: # 一致したら “Yes”と言って終わり print(“Yes”); exit() # 見つからなかったので No print(“No”) #include <stdio.h> int main (void) { int n, i, j; scanf(“%d”, &n); for (i = 0; i < 10; i++) for (j = 0; j < 10; j++) if (i * j == n) { printf(“Yes¥n”); return 0; } printf(“No¥n”); } 1ZUIPOͷྫ $ͷྫ
% i == 0 and n / i < 10: print(“Yes”); exit() print(“No”) #include <stdio.h> int main (void) { int n, i; scanf(“%d”, &n); for (i = 1; i < 10; i++) if (n % i == 0 && n / i < 10) { printf(“Yes¥n”); return 0; } printf(“No¥n”); } 1ZUIPOͷྫ $ͷྫ
top = x // 絶対買えない while top – bottom > 1: med = (top + bottom) // 2 if med + math.sqrt(med) > x: top = med else: bottom = med print (bottom) #include <stdio.h> #include <math.h> int main (void) { int x, bottom, top; scanf(“%d”, &x); top = x, bottom = 0; while (top – bottom > 0) { int med = (top + bottom) / 2; if (med + sqrt(med) > x) top = med; else bottom = med; } printf(“%d¥n”, bottom); } 1ZUIPOͷྫ $ͷྫ
from in range(0, n): for to in range(i, n): sum = 0 for i in range(from, to + 1): sum += a[i] if sum <= 100: if to – from + 1 > max: max = to – from + 1 print(max) #include <stdio.h> int main (void) { int n, a[300], i, from, to, max = 0; scanf(“%d”, &n); for (i = 0; i < n; i++) scanf(“%d”, &a[i]); for (from = 0; from < n; from++) for (to = sum = 0; to < n; to++) { for (i = from; i <= to; i++) sum += a[i] if (sum <= 100) if (to – from + 1 > max) max = to – from + 1; } printf(“%d¥n”, max); } 1ZUIPOͷྫ $ͷྫ