結果

問題 No.403 2^2^2
ユーザー anta
提出日時 2016-07-21 01:29:20
言語 C++14
(gcc 8.3.0)
結果
AC  
実行時間 4 ms
コード長 2,703 Byte
コンパイル時間 1,355 ms
使用メモリ 1,468 KB
最終ジャッジ日時 2019-11-26 11:54:49

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
0_sample_01.in AC 3 ms
1,468 KB
0_sample_02.in AC 3 ms
1,464 KB
0_sample_03.in AC 2 ms
1,468 KB
1_small_01.in AC 3 ms
1,464 KB
1_small_02.in AC 3 ms
1,464 KB
1_small_03.in AC 3 ms
1,464 KB
1_small_04.in AC 3 ms
1,464 KB
1_small_05.in AC 2 ms
1,468 KB
1_small_06.in AC 2 ms
1,464 KB
1_small_07.in AC 3 ms
1,468 KB
2_large_01.in AC 3 ms
1,468 KB
2_large_02.in AC 2 ms
1,464 KB
2_large_03.in AC 3 ms
1,468 KB
2_large_04.in AC 3 ms
1,464 KB
2_large_05.in AC 3 ms
1,464 KB
2_large_06.in AC 3 ms
1,468 KB
2_large_07.in AC 3 ms
1,464 KB
2_large_08.in AC 3 ms
1,464 KB
2_large_09.in AC 3 ms
1,464 KB
2_large_10.in AC 3 ms
1,468 KB
2_large_11.in AC 3 ms
1,464 KB
2_large_12.in AC 3 ms
1,464 KB
2_large_13.in AC 3 ms
1,464 KB
2_large_14.in AC 4 ms
1,468 KB
2_large_15.in AC 3 ms
1,468 KB
2_large_16.in AC 3 ms
1,464 KB
2_large_17.in AC 3 ms
1,464 KB
2_large_18.in AC 3 ms
1,464 KB
2_large_19.in AC 3 ms
1,464 KB
challenge01.txt AC 3 ms
1,468 KB
テストケース一括ダウンロード

ソースコード

diff #
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

#ifdef NDEBUG
#error assert is disabled!
#endif

template<typename T>
T readNatural(T lo, T up) {
	assert(0 <= lo && lo <= up);
	T x = 0;
	while(1) {
		int d = getchar();
		if(!('0' <= d && d <= '9')) {
			ungetc(d, stdin);
			break;
		}
		d -= '0';
		assert(d <= up && x <= (up - d) / 10);
		x = x * 10 + d;
	}
	assert(lo <= x && x <= up);
	return x;
}

void readSpace() { int c = getchar(); assert(c == ' '); }
void readChar(char t) { int c = getchar(); assert(c == t); }
static bool read_eof = false;
void readEOL() {
	int c = getchar();
	if(c == EOF) {
		assert(!read_eof);
		read_eof = true;
	} else {
		assert(c == '\n');
	}
}
void readEOF() {
	assert(!read_eof);
	int c = getchar();
	assert(c == EOF);
	read_eof = true;
}

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) {}
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
	ModInt<MOD> r = 1;
	while(k) {
		if(k & 1) r *= a;
		a *= a;
		k >>= 1;
	}
	return r;
}
typedef ModInt<1000000007> mint;
typedef ModInt<1000000006> mintphi;

int main() {
	ll A = readNatural(1LL, (ll)1e16); 
	readChar('^');
	ll B = readNatural(1LL, (ll)1e16);
	readChar('^');
	ll C = readNatural(1LL, (ll)1e16);
	readEOL();
	readEOF();
	mint ans1 = (mint(A) ^ B) ^ C;
	mintphi e = mintphi(B) ^ C;
	mint ans2 = A % mint::Mod == 0 ? mint() : mint(A) ^ e.get();
	printf("%d %d\n", ans1.get(), ans2.get());
	return 0;
}
0