답안 #165207

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165207 2019-11-26T03:05:08 Z coloredrabbit Ω (kriii4_P3) C++17
0 / 100
2 ms 376 KB
#include <cstdio>
using ll = long long;
const ll MOD = 1e9 + 7;
ll _pow(ll a, int n) {
	if (n == 0) return 1;
	ll ret = _pow(a, n / 2);
	ret = (ret * ret) % MOD;
	if (n & 1) ret = (ret * a) % MOD;
	return ret;
}
ll gcd(ll p, ll q) { return !q ? p : gcd(q, p % q); }
ll rev(ll x) { return _pow(x, MOD - 2); }
int main() {
	int P, Q, N, K;
	ll v, ans = 0, A, B, g, X;
	scanf("%d%d%d%d", &P, &Q, &N, &K);
	if (K == 0 || Q == P) puts("0");
	else if (K == N || Q == 0) puts("1");
	else {
		if (2 * Q == P)
			ans = K * rev(N) % MOD;
		else {
			v = Q * rev(P - Q);
			ans = ((1 - _pow(v, K) + MOD) % MOD) * (rev(1 - _pow(v, N) + MOD) % MOD) % MOD;
		}
		printf("%lld", ans);
	}

	return 0;
}

Compilation message

P3.cpp: In function 'int main()':
P3.cpp:15:17: warning: unused variable 'A' [-Wunused-variable]
  ll v, ans = 0, A, B, g, X;
                 ^
P3.cpp:15:20: warning: unused variable 'B' [-Wunused-variable]
  ll v, ans = 0, A, B, g, X;
                    ^
P3.cpp:15:23: warning: unused variable 'g' [-Wunused-variable]
  ll v, ans = 0, A, B, g, X;
                       ^
P3.cpp:15:26: warning: unused variable 'X' [-Wunused-variable]
  ll v, ans = 0, A, B, g, X;
                          ^
P3.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &P, &Q, &N, &K);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 128 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -