結果

問題 No.492 IOI数列
ユーザー pazzle1230pazzle1230
提出日時 2017-03-11 01:50:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 2,813 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 93,364 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 15:05:32
合計ジャッジ時間 1,608 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 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,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

template<typename T>
void chmax(T &a, T &b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T &b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

class RMQ{
	vector<int> dat;
	int n;
public:
	RMQ(int n_){
		n = 1;
		while(n < n_) n *= 2;
		REP(i, n*2-1){
			dat.push_back(INF);
		}
	}

	void update(int x, int i){
		i += n-1;
		dat[i] = x;
		while(i > 0){
			i = (i-1)/2;
			dat[i] = min(dat[i*2+1], dat[i*2+2]);
		}
	}

	int query(int a, int b, int l, int r, int k){
		if(a <= l && r <= b) return dat[k];
		if(b <= l || r <= a) return INF;

		return min(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2, r, k*2+2));
	}

	int query(int a, int b){
		return query(a, b, 0, n, 0);
	}
};

ll con = 1000000001;
const ll mod = 1e9+7;

int keta(ll n){
	int res = 0;
	while(n > 0){
		n /= 10;
		res++;
	}
	return res;
}

/*
ll dbl(ll n, int f){
	ll res = n * pow(10, keta(n)-f);
	int p = keta(n)-1-f;

	if(f)
		n /= 10;
	while(n > 0){
		res += (n%10)*pow(10, p);
		n/=10;
		p--;
	}
	return res;
}

int main(void){
	ll N;
	ll res = 0;
	//cin >> N;
	N = con*210;
	N /= con;
	int p = 0;
	int flag = keta(N)%2;
	int dig = keta(N);
	int f = 1;
	REP(i, dig-1){
		if(i < 2){
			res += 9;
		}else{
			res += (ll)9*pow(10, (i+1)/2+(i+1)%2-1);
		}
	}
	for(ll i = pow(10, dig/2+dig%2-1);dbl(i, dig%2) <= N;i++){
		res++;
	}
	cout << res << endl;
}
*/

ll powm(ll n, ll b){
	if(b == 0) return 1;
	ll res = powm(n, b/2)%mod;
	if(b%2) return (((res*res)%mod)*n)%mod;
	return (res*res)%mod;
}

ll gen(ll n){
	if(n == 1) return 1;
	if(n % 2){
		ll res = (gen(n-1)*100+1)%mod;
		return res;
	}else{
		ll res = (gen(n/2)*(powm(100, n/2)+1)%mod)%mod;
		return res;
	}
}

int main(void){
	ll N;
	cin >> N;
	cout << gen(N) << endl;
	REP(i, N%11-1){
		cout << 10;
	}
	if(N%11)
		cout << 1 << endl;
	else
		cout << 0 << endl;
}
0