結果

問題 No.1177 余りは?
ユーザー achapiachapi
提出日時 2023-04-30 18:15:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 125 ms / 1,000 ms
コード長 473 bytes
コンパイル時間 5,174 ms
コンパイル使用メモリ 262,048 KB
実行使用メモリ 11,848 KB
最終ジャッジ日時 2024-04-29 23:14:47
合計ジャッジ時間 7,777 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
5,580 KB
testcase_01 AC 125 ms
11,848 KB
testcase_02 AC 36 ms
5,580 KB
testcase_03 AC 86 ms
7,628 KB
testcase_04 AC 47 ms
5,580 KB
testcase_05 AC 57 ms
5,580 KB
testcase_06 AC 16 ms
5,376 KB
testcase_07 AC 15 ms
5,376 KB
testcase_08 AC 105 ms
7,628 KB
testcase_09 AC 93 ms
7,628 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 63 ms
7,628 KB
testcase_12 AC 12 ms
5,376 KB
testcase_13 AC 22 ms
5,376 KB
testcase_14 AC 29 ms
5,704 KB
testcase_15 AC 42 ms
5,584 KB
testcase_16 AC 33 ms
5,580 KB
testcase_17 AC 108 ms
7,500 KB
testcase_18 AC 52 ms
5,584 KB
testcase_19 AC 74 ms
7,496 KB
testcase_20 AC 23 ms
5,376 KB
testcase_21 AC 66 ms
7,628 KB
testcase_22 AC 99 ms
7,500 KB
testcase_23 AC 53 ms
5,584 KB
testcase_24 AC 33 ms
5,576 KB
testcase_25 AC 87 ms
7,500 KB
testcase_26 AC 102 ms
7,628 KB
testcase_27 AC 22 ms
5,376 KB
testcase_28 AC 65 ms
7,496 KB
testcase_29 AC 59 ms
7,624 KB
testcase_30 AC 56 ms
5,580 KB
testcase_31 AC 76 ms
7,588 KB
testcase_32 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using mint = atcoder::modint1000000007;

int main() {
	int p, k;
	cin >> p >> k;
	vector<int> a;
	int c = 1;
	for (int i = 0; i < p; i++){
		while (c < p){
			c *= 10;
			a.push_back(0);
		}
		a.pop_back();
		a.push_back(c / p);
		c -= c / p * p;
	}
	mint ans = 0;
	for (int i = 2; i < p + 1; i++){
		ans += mint(a[p - i]) * mint(10).pow(i - 2);
	}
	if (k == 0){
		ans++;
	}
	cout << ans.val() << endl;
}
0