Submission #64526529
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
struct LIST {
//int data; // 要素
int num; // 要素
struct LIST* next; // 次のデータの場所(ポインタ)
};
static void swap(int* a, int* b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void quick_sort(int* a, int get_left, int get_right)
{
int left = get_left, right = get_right - 1, standard = get_right;
if (left <= right)
{
while (left < right)
{
// 基準以下・以上の
while (a[left] < a[standard] && left < right)
{
left++;
}
while (a[right] > a[standard] && left < right)
{
right--;
}
if (left < right)
{
swap(&a[left], &a[right]);
left++;
right--;
}
}
if (a[left] < a[standard])
{
left += 1;
}
swap(&a[left], &a[standard]);
quick_sort(a, get_left, left - 1);
quick_sort(a, left + 1, get_right);
}
}
int binary_search(int target, int* a, int get_left, int get_right)
{
int now = (get_left + get_right) / 2;
if (a[now] == target)
{
return now;
}
else if (get_left == get_right)
{
return - 1;
}
else if (target < a[now])
{
return binary_search(target, a, get_left, now - 1);
}
else if (a[now] < target)
{
return binary_search(target, a, now + 1, get_right);
}
}
int main(void) {
int max_M = 3 * pow(10, 5);
int i, j, k;
int count = 0, temp = 0;
int N, M;
double sum = 0;
scanf("%d %d", &N, &M);
if (N == 1)
{
printf("%d", M + 1);
}
else if (M >= 30)
{
printf("inf");
}
else
{
temp = N;
while (temp >= 10)
{
temp /= 10;
count++;
if (count > 10)
{
break;
}
}
if ((count * M) > 9)
{
printf("inf");
}
else
{
for (i = M; i >= 0; i--)
{
sum += pow(N, i);
if (sum > pow(10, 9))
{
break;
}
}
if (sum > pow(10, 9))
{
printf("inf");
}
else
{
printf("%d", (int)sum);
}
}
}
return 0;
}
Submission Info
Submission Time
2025-04-05 21:28:46+0900
Task
B - Sum of Geometric Series
User
purazuma
Language
C (gcc 12.2.0)
Score
200
Code Size
2064 Byte
Status
AC
Exec Time
1 ms
Memory
2364 KiB
Compile Error
Main.c: In function ‘main’:
Main.c:87:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
87 | scanf("%d %d", &N, &M);
| ^~~~~~~~~~~~~~~~~~~~~~
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
200 / 200
Status
Set Name
Test Cases
Sample
sample00.txt, sample01.txt, sample02.txt, sample03.txt
All
sample00.txt, sample01.txt, sample02.txt, sample03.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt
Case Name
Status
Exec Time
Memory
sample00.txt
AC
1 ms
2220 KiB
sample01.txt
AC
1 ms
2024 KiB
sample02.txt
AC
1 ms
2264 KiB
sample03.txt
AC
1 ms
1996 KiB
testcase00.txt
AC
1 ms
2088 KiB
testcase01.txt
AC
1 ms
2024 KiB
testcase02.txt
AC
1 ms
2028 KiB
testcase03.txt
AC
1 ms
2196 KiB
testcase04.txt
AC
1 ms
2264 KiB
testcase05.txt
AC
1 ms
2172 KiB
testcase06.txt
AC
1 ms
2232 KiB
testcase07.txt
AC
1 ms
2176 KiB
testcase08.txt
AC
1 ms
2092 KiB
testcase09.txt
AC
1 ms
2192 KiB
testcase10.txt
AC
1 ms
2252 KiB
testcase11.txt
AC
1 ms
2364 KiB
testcase12.txt
AC
1 ms
2176 KiB
testcase13.txt
AC
1 ms
2236 KiB
testcase14.txt
AC
1 ms
2092 KiB
testcase15.txt
AC
1 ms
2224 KiB
testcase16.txt
AC
1 ms
2268 KiB
testcase17.txt
AC
1 ms
1944 KiB
testcase18.txt
AC
1 ms
1968 KiB
testcase19.txt
AC
1 ms
2012 KiB
testcase20.txt
AC
1 ms
1852 KiB
testcase21.txt
AC
1 ms
2008 KiB
testcase22.txt
AC
0 ms
2020 KiB
testcase23.txt
AC
1 ms
1904 KiB
testcase24.txt
AC
1 ms
2004 KiB
testcase25.txt
AC
1 ms
1908 KiB
testcase26.txt
AC
1 ms
2268 KiB
testcase27.txt
AC
1 ms
1908 KiB
testcase28.txt
AC
1 ms
2032 KiB
testcase29.txt
AC
1 ms
2024 KiB
testcase30.txt
AC
1 ms
1924 KiB
testcase31.txt
AC
1 ms
2024 KiB
testcase32.txt
AC
1 ms
2096 KiB