結果
| 問題 |
No.2007 Arbitrary Mod (Easy)
|
| コンテスト | |
| ユーザー |
taisii2
|
| 提出日時 | 2022-07-15 21:37:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 451 bytes |
| コンパイル時間 | 1,483 ms |
| コンパイル使用メモリ | 165,860 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 17:07:57 |
| 合計ジャッジ時間 | 4,011 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long b) {
long long ans = 1;
while (b > 0) {
if (b & 1) {
ans *= a;
}
a *= a;
b /= 2;
}
return ans;
}
int main() {
long long a, n;
cin >> a >> n;
long long mod = a;
int c = 1;
while (mod < 1E7) {
mod *= a;
c++;
}
cout << mod << endl;
if (c <= n) {
cout << 0 << endl;
} else {
cout << pow(a, n) << endl;
}
}
taisii2