結果

問題 No.1177 余りは?
ユーザー pockyny
提出日時 2020-08-22 00:15:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 413 bytes
コンパイル時間 796 ms
コンパイル使用メモリ 66,560 KB
最終ジャッジ日時 2025-01-13 06:37:52
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll pw(ll a,ll x,ll y){
    ll ret = 1;
    while(x){
        if(x&1) (ret *= a) %= y;
        x /= 2; (a *= a) %= y;
    }
    return ret;
}

int main(){
    ll p,k; cin >> p >> k;
    (k *= pw(10,p - 2,p)) %= p;
    ll ans = (pw(10,p - 1,mod) + mod - 1)%mod*pw(p,mod - 2,mod)%mod;
    if(k==0) ans++;
    cout << ans << endl;
}
0