結果

問題 No.2177 Recurring ab
ユーザー 👑 chro_96chro_96
提出日時 2023-01-06 22:08:42
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,014 bytes
コンパイル時間 1,385 ms
コンパイル使用メモリ 29,108 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 15:18:58
合計ジャッジ時間 2,368 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 0 ms
4,380 KB
testcase_12 AC 0 ms
4,380 KB
testcase_13 AC 0 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 0 ms
4,380 KB
testcase_17 AC 0 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 0 ms
4,376 KB
testcase_20 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  long long n = 0LL;
  
  int res = 0;
  
  long long ans = 0LL;
  long long prev_p = 9LL;
  long long cnt = 0LL;
  
  res = scanf("%lld", &n);
  
  for (int a = 0; a < 10; a++) {
    for (int b = 0; b < 10; b++) {
      if (a != b && prev_p < 1000000000LL) {
        long long nxt_p[2] = { prev_p, 1000000001LL };
        while (nxt_p[1]-nxt_p[0] > 1LL) {
          long long nxt = (nxt_p[0]+nxt_p[1])/2LL;
          if (n*(nxt*((long long)a)+((long long)b)) > nxt*nxt-1LL) {
            nxt_p[0] = nxt;
          } else {
            nxt_p[1] = nxt;
          }
        }
        ans += (nxt_p[0]-prev_p)*cnt;
        prev_p = nxt_p[0];
        cnt += 1LL;
      }
    }
  }
  
  ans = (prev_p-9LL)*90LL-ans;
  
  for (int i = 2; i < 10; i++) {
    for (int a = 0; a < i; a++) {
      for (int b = 0; b < i; b++) {
        if (a != b && n*((long long)(i*a+b)) > ((long long)(i*i-1))) {
          ans += 1LL;
        }
      }
    }
  }
  
  printf("%lld\n", ans);
  return 0;
}
0