結果

問題 No.1177 余りは?
コンテスト
ユーザー merom686
提出日時 2020-08-21 23:07:05
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 637 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 722 ms
コンパイル使用メモリ 106,432 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-12 15:15:00
合計ジャッジ時間 2,229 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k, ll p) {
    ll r = 1, t = n % p;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % p;
        t = t * t % p;
    }
    return r;
}
ll modinv(ll n) {
    return powmod(n, P - 2, P);
}

int main() {
    int p, k;
    cin >> p >> k;

    ll s = (powmod(10, p - 1, p) + p - 1 - k) % p;
    ll r = (powmod(10, p - 1, P) + p - 1 - k + (P - s)) % P * modinv(p) % P;

    cout << r << endl;

    return 0;
}
0