結果

問題 No.1580 I like Logarithm!
ユーザー 37zigen37zigen
提出日時 2021-07-03 01:17:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 617 bytes
コンパイル時間 1,113 ms
コンパイル使用メモリ 60,076 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 04:33:50
合計ジャッジ時間 5,257 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 43 ms
4,380 KB
testcase_07 AC 104 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 7 ms
4,380 KB
testcase_10 AC 13 ms
4,376 KB
testcase_11 AC 64 ms
4,380 KB
testcase_12 AC 71 ms
4,376 KB
testcase_13 AC 56 ms
4,376 KB
testcase_14 AC 103 ms
4,376 KB
testcase_15 AC 80 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 109 ms
4,376 KB
testcase_27 AC 109 ms
4,376 KB
testcase_28 AC 109 ms
4,376 KB
testcase_29 AC 109 ms
4,376 KB
testcase_30 AC 109 ms
4,376 KB
testcase_31 AC 109 ms
4,376 KB
testcase_32 AC 109 ms
4,384 KB
testcase_33 AC 109 ms
4,376 KB
testcase_34 AC 110 ms
4,376 KB
testcase_35 AC 109 ms
4,376 KB
testcase_36 AC 109 ms
4,380 KB
testcase_37 AC 109 ms
4,376 KB
testcase_38 AC 108 ms
4,376 KB
testcase_39 AC 109 ms
4,376 KB
testcase_40 AC 109 ms
4,380 KB
testcase_41 AC 109 ms
4,376 KB
testcase_42 AC 110 ms
4,376 KB
testcase_43 AC 109 ms
4,376 KB
testcase_44 AC 111 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) + p) * (i-1) % p;
				x%=p;
		}
		cout << x << endl;
}
0