結果

問題 No.1580 I like Logarithm!
ユーザー 37zigen37zigen
提出日時 2021-07-03 01:15:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 613 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 70,576 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-12 04:32:53
合計ジャッジ時間 6,173 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 41 ms
4,380 KB
testcase_07 AC 100 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 7 ms
4,380 KB
testcase_10 AC 12 ms
4,380 KB
testcase_11 WA -
testcase_12 AC 68 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 76 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 104 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 104 ms
4,380 KB
testcase_33 AC 104 ms
4,376 KB
testcase_34 AC 104 ms
4,380 KB
testcase_35 AC 103 ms
4,376 KB
testcase_36 AC 104 ms
4,376 KB
testcase_37 AC 104 ms
4,380 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 104 ms
4,380 KB
testcase_44 AC 103 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<list>

using namespace std;
long long p=(long long) 1e9+7;

long long powmod(long long a, long long n) {
		return n!=0?powmod(a*a%p,n/2)*(n%2==1?a:1)%p:1;
}

long long tolong(string B, long long A) {
		long long x=0;
		for (int i=0;i<B.size();++i) {
				x=x*A%p;
				x+=(int)(B[i]-'0');
		}
		return x;
}

int main() {
		long long x = 0;
		int A;
		string B;
		cin >> A;
		cin >> B;
		int n=B.size();
		long long upper=(tolong(B,A)+1)%p;
		for (int i=1;i<=n;++i) {
				x+= ((i==n?upper:powmod(A, i)) - powmod(A, i-1)) * (i-1) % p;
				x%=p;
		}
		cout << x << endl;
}
0