結果
問題 |
No.251 大きな桁の復習問題(1)
|
ユーザー |
![]() |
提出日時 | 2015-07-25 11:11:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 601 bytes |
コンパイル時間 | 1,146 ms |
コンパイル使用メモリ | 157,536 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-16 04:48:12 |
合計ジャッジ時間 | 1,956 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%s", N); | ~~~~~^~~~~~~~~ main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%s", M); | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h> int main() { char N[1048576]; char M[1048576]; uint64_t p = 129402307; scanf("%s", N); scanf("%s", M); int N_size = strlen(N); int M_size = strlen(M); uint64_t n = 0; uint64_t m = 0; for(int i = 0; i < N_size; ++i) { n = (n * 10 + (N[i] - '0')) % p; } for(int i = 0; i < M_size; ++i) { m = (m * 10 + (M[i] - '0')) % (p - 1); } uint64_t ans = 1; while( m != 0 ) { if( (m & 0x01) != 0 ) { ans = ans * n % p; } n = (n * n) % p; m >>= 1; } printf("%ld\n", ans); return 0; }