結果

問題 No.820 Power of Two
ユーザー kame_2211kame_2211
提出日時 2019-05-03 21:26:08
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 2,412 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 30,756 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 05:54:14
合計ジャッジ時間 871 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define ROOP(i,n) for(i=0;i<n;i++)

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void intpr(int i);
void prllint(long long i);
void prdint(double i);
void prchar(char c);
void prstring(char *s);
int dfs(int v, int n, int *visited, int table[n][n]);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが1のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main(void) {
	int i, n, k, ans = 0;
	n = getint();
	k = getint();
	int q = myPower(2, n - k);
	if (n >= k) {
		intpr(q);
	} else {
		intpr(0);
	}
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void intpr(int i) {
	printf("%d\n", i);
}

void prllint(long long i) {
	printf("%lld\n", i);
}

void prdint(double i) {
	printf("%lf\n", i);
}

void prchar(char c) {
	printf("%c\n", c);
}

void prstring(char *s) {
	printf("%s\n", s);
}

int dfs(int v, int n, int *visited, int table[n][n]) {
	int all_visited = 1, i;

	ROOP(i,n) {
		if (!visited[i]) {
			all_visited = 0;
			break;
		}
	}

	if (all_visited) {
		return 1;
	}

	int count = 0;

	ROOP(i,n) {
		if (!table[v][i]) continue;
		if (visited[i]) continue;

		visited[i] = 1;
		count += dfs(i, n, visited, table);
		visited[i] = 0;
	}

	return count;
}

int gcd(int a, int b) {
	int r;

	if (a < b) {
		r = a;
		a = b;
		b = r;
	}

	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

int lcm(int a, int b) {
	int r = llgcd(a, b);
	a /= r;
	return a * b;
}

long long llgcd(long long a, long long b) {
	long long r;

	if (a < b) {
		r = a;
		a = b;
		b = r;
	}

	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long lllcm(long long a, long long b) {
	long long r = llgcd(a, b);
	a /= r;
	return a * b;
}
0