PKU 1422. Air raid. WA -_-....
#include int found[10001][10001]; int result[10001][10001]; int main() { int cases, inters, streets, start, end, i, j, k, l, sum; scanf("%d", &cases); while (cases--) { scanf("%d", &inters); scanf("%d", &streets); while (streets--) { scanf("%d%d", &start, &end); found[start][end] = 1; result[start][end] = 1; } for (i = 1; i < inters; i++) { for (j = 1; j
더보기
PKU 2844. Sum and Product. TLE -_-
#include __int64 multipoint[100000]; __int64 factors[100000]; int main() { __int64 n, s, p, factnum, i, j, sum, prod, count; while(~scanf("%d%d%d", &n, &s, &p)) { /* initialize & input */ factnum = 0; for (i = 1; i < s; i++) { if (p % i == 0) { factors[factnum] = i; factnum++; } } for (i = 0; i < n; i++) { multipoint[i] = factnum - 1; } /* calculating */ while (multipoint[n - 1] != 0) { for (i =..
더보기
PKU 2844. 합과 곱. 스풰샬 스퉤이지~
N개짜리 정수 수열 A1, A2, ... , AN가 있습니다. 우리는 이를 이용해 이들의 합 S와 곱 P를 쉽게 구할 수 있지요(.... 웃기고 있네;;;). 주어진 N과 S, P를 이용해 수열 A1, A2, ... , AN를 구할 수 있을까요? 입력 한 줄에 N, S, P 세개만 입력됩니다. N은 1000000을 넘지 않으며, S와 P는 150000000을 넘지 않습니다. 출력 해답이 존재하지 않는다면 "No Solution"을, 존재한다면 해당 수열을 출력하여 주세요. 입력 예시sample input#1 2 4 3 sample input#2 4 4 2 출력 예시sample output#1 1 3 sample output#2 No solution 출처 POJ Monthly--2006.06.25, Yan..
더보기
PKU 2844. Sum and Product. 스풰샬 스퉤이지~
For a sequence of N integers A1, A2, ... , AN, we can calculate their sum S and product P easily. With given N, S and P, can you find out the sequence A1, A2, ... , AN? Input The input only contains a line with three integers N, S and P. Here N is positive and not more than 1000000, and the absolute values of S and P do not exceed 150000000. Output Just output "No solution" if there is no such s..
더보기