読者です 読者をやめる 読者になる 読者になる

夢追い人

"It takes a dreamer to make a dream come true."―Vincent Willem van Gogh

hatena銀色になった

0044

#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int n;
	bool isprime[70001];
	int prime[35000];
	int pnum = 0;
	fill(isprime, isprime+70001, true);
	isprime[0] = isprime[1] = false;
	for (int i=2; i<70001; i++) {
		if (isprime[i]) {
			for (int j=i+i; j<70001; j+=i) isprime[j] = false;
		}
	}
	for (int i=2; i<70001; i++) {
		if (isprime[i]) {
			prime[pnum++] = i;
		}
	}
/*	for (int i=0; i<100; i++) {
		printf("%d ",prime[i]);
	}
	printf("\n");
*/
	while (scanf("%d", &n)!=EOF) {
		int a, b;
		for (int i=0; i<35000; i++) {
			if (prime[i] > n) {
				a = prime[i-1];
				b = prime[i];
				break;
			} else if (prime[i] == n) {
				a = prime[i-1];
				b = prime[i+1];
				break;
			}
		}
		printf("%d %d\n", a, b);
	}
}

0038

#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
/* null
 * one pair
 * two pair
 * three card
 * straight
 * full house
 * four card
 * */
int main() {
	vector<int> cards(5);
	while (scanf("%d,%d,%d,%d,%d",&cards[0],&cards[1],&cards[2],
				&cards[3],&cards[4])!=EOF) {
		vector<int> cnt(13, 0);
		for (int i=0; i<5; i++) cnt[cards[i]-1]++;
		int two = 0, three = 0, four = 0;
		for (int i=0; i<13; i++) {
			if (cnt[i] == 2) two++;
			if (cnt[i] == 3) three++;
			if (cnt[i] == 4) four++;
		}
		if (four == 1) {
			printf("four card\n");
			continue;
		} else if (two == 1 && three == 1) {
			printf("full house\n");
			continue;
		} else if (three == 1) {
			printf("three card\n");
			continue;
		} else if (two == 2) {
			printf("two pair\n");
			continue;
		} else if (two == 1) {
			printf("one pair\n");
			continue;
		}
		int c = 0;
		bool flag = false;
		for (int i=0; i<9; i++) {
			if (cnt[i] == 1) {
				if (cnt[i+1]==1&&cnt[i+2]==1&&cnt[i+3]==1&&
						cnt[i+4]==1) {
					flag = true;
					break;
				}
			}
		}
		if (flag||
				(cnt[9]==1&&cnt[10]==1&&cnt[11]==1&&cnt[12]==1&&cnt[0]==1)) {
			printf("straight\n");
		} else {
			printf("null\n");
		}
	}	
}
広告を非表示にする