Submission #856654


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

long long f(long long b, long long n) {
  long long modsum = 0;
  while (n >= b) {
	modsum += (n % b);
	n = floor(n/b);
  }
  modsum += n;
  return modsum;
}

int main() {
  long long n, s;
  scanf("%lld", &n);
  scanf("%lld", &s);

  bool found;
  for (long long b = 2; b <= n; b++) {
	if (f(b,n) == s) {
	  printf("%lld\n", b);
	  found = true;
	  break;
	}
  }
  if (not found) {
	printf("-1\n");
  }
  return 0;
}

Submission Info

Submission Time
Task C - Tak and Cards
User sozos
Language C++14 (GCC 5.4.1)
Score 0
Code Size 496 Byte
Status WA
Exec Time 5 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:17:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &n);
                    ^
./Main.cpp:18:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &s);
                    ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 100
Status
WA × 4
WA × 12
WA × 24
Set Name Test Cases
Sample example_01.txt, example_02.txt, example_03.txt, example_04.txt
Subtask1 example_01.txt, example_02.txt, example_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt
All example_01.txt, example_02.txt, example_03.txt, example_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt
Case Name Status Exec Time Memory
example_01.txt WA 4 ms 256 KB
example_02.txt WA 4 ms 256 KB
example_03.txt WA 4 ms 256 KB
example_04.txt WA 4 ms 256 KB
subtask1_01.txt WA 4 ms 256 KB
subtask1_02.txt WA 4 ms 256 KB
subtask1_03.txt WA 4 ms 256 KB
subtask1_04.txt WA 4 ms 256 KB
subtask1_05.txt WA 4 ms 256 KB
subtask1_06.txt WA 4 ms 256 KB
subtask1_07.txt WA 4 ms 256 KB
subtask1_08.txt WA 4 ms 256 KB
subtask1_09.txt WA 4 ms 256 KB
subtask2_01.txt WA 4 ms 256 KB
subtask2_02.txt WA 5 ms 256 KB
subtask2_03.txt WA 4 ms 256 KB
subtask2_04.txt WA 4 ms 256 KB
subtask2_05.txt WA 4 ms 256 KB
subtask2_06.txt WA 4 ms 256 KB
subtask2_07.txt WA 4 ms 256 KB
subtask2_08.txt WA 4 ms 256 KB
subtask2_09.txt WA 4 ms 256 KB
subtask2_10.txt WA 4 ms 256 KB
subtask2_11.txt WA 4 ms 256 KB