結果

問題 No.492 IOI数列
ユーザー bal4ubal4u
提出日時 2019-04-17 07:38:12
言語 C
(gcc 12.3.0)
結果
OLE  
実行時間 -
コード長 888 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 30,148 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 07:17:50
合計ジャッジ時間 4,334 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 OLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.492 IOI数列
// 2019.4.17 bal4u
//
// 101数の第n項目:
// a_1 = 1, a_2 = 100+1, a_3 = 100^2+100+1, a_n = (100^n-1)/99
//
// mod m (m=10^9+7)についてのメモ
// mは素数。99^(-1)つまり99の逆元=99^(m-2)=646464651 なので
// (100^n-1)/99 mod m → (100^(n%(m-1))+m-1)*646464651 mod m

#include <stdio.h>

#define MOD 1000000007  // 10^9+7
int bigPow(int x, int p, int mod)
{
	int r = 1;
	while (p) {
		if (p & 1) r = (long long)r * x % mod;
		x = (long long)x * x % mod;
		p >>= 1;
	}
	return (r % mod);
}

int calc_109_7(long long n)
{
	int p = (int)(n % (MOD-1));
	long long a = bigPow(100, p, MOD);
	a = (a + MOD-1) * 646464651LL;
	return a % MOD;
}

int main()
{
	int k;
	long long N;
	scanf("%lld", &N);
	printf("%d\n", calc_109_7(N));
	putchar('1');
	k = (int)(N % 11)-1;
	while (k--) putchar('0'), putchar('1');
	putchar('\n');
	return 0;
}
0