알고리즘/SW Expert Academy
[D4] 7965. 퀴즈
혬혬
2019. 10. 6. 11:10
728x90
#include <stdio.h>
long long sequal[1000002][2] = { 0 };
int main() {
int test_case = 0;
scanf("%d", &test_case);
char buffer = 0;
scanf("%c", &buffer);
long long last_point = 0;
sequal[0][0] = 0;
sequal[0][1] = 0;
for (int q = 0; q < test_case; q++) {
long long number = 0;
scanf("%d", &number);
for (int i = last_point+1; i <= number; i++) {
long long box = 1;
long long y = i;
long long x = i;
while (y)
{
if (y % 2 == 1)//홀수 체크 (y&1)
{
box = (box * x) % 1000000007;
}
x = (x * x) % 1000000007;
y /= 2;
}
sequal[i][0] = box;
sequal[i][1] = (sequal[i - 1][1] + box) % 1000000007;
}
if(last_point<number)
last_point = number;
printf("#%d %ld\n", q + 1, sequal[number][1]);
}
return 0;
}
728x90