Submission #20327966


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int main(){
	long long int a = 0;
	string s;
	long long int n;
	cin >> s;
	cin >> n;
	int m=0;
	for(int i = 0;i<s.size();i++){
		if(m<s[i]-48){
			m = s[i]-48;
		}
	}
	long long int d = m+1;
	long long int sum = 0;
	while(1){
		sum = 0;
		for(long long int i = 0;i<s.size();i++){
			long long int b = 1;
			for(long long int j = 0;j<i;j++){
				 b *= d;
		}	
			sum += b*(s[i]-48);
		}
		if(sum > n){
			break;
		}
		a += 1;
		d += 1;
	}
	cout << a;
	return 0;
}

Submission Info

Submission Time
Task D - Base n
User hocashi
Language C++ (GCC 9.2.1)
Score 0
Code Size 543 Byte
Status WA
Exec Time 2205 ms
Memory 3604 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:11:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   11 |  for(int i = 0;i<s.size();i++){
      |                ~^~~~~~~~~
./Main.cpp:20:28: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   20 |   for(long long int i = 0;i<s.size();i++){
      |                           ~^~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 2
TLE × 1
AC × 20
WA × 13
TLE × 14
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, one_digit_01.txt, one_digit_02.txt, one_digit_03.txt, one_digit_04.txt, one_digit_05.txt, one_digit_06.txt, one_digit_07.txt, one_digit_08.txt, one_digit_09.txt, one_digit_10.txt, one_digit_11.txt, one_digit_12.txt, one_digit_13.txt, one_digit_14.txt, one_digit_15.txt, one_digit_16.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 6 ms 3560 KiB
hand_02.txt TLE 2205 ms 3400 KiB
hand_03.txt AC 9 ms 3520 KiB
hand_04.txt TLE 2205 ms 3396 KiB
one_digit_01.txt TLE 2205 ms 3224 KiB
one_digit_02.txt AC 8 ms 3448 KiB
one_digit_03.txt AC 2 ms 3392 KiB
one_digit_04.txt AC 2 ms 3604 KiB
one_digit_05.txt TLE 2205 ms 3396 KiB
one_digit_06.txt TLE 2205 ms 3224 KiB
one_digit_07.txt AC 9 ms 3584 KiB
one_digit_08.txt AC 3 ms 3556 KiB
one_digit_09.txt TLE 2205 ms 3328 KiB
one_digit_10.txt TLE 2205 ms 3344 KiB
one_digit_11.txt TLE 2205 ms 3284 KiB
one_digit_12.txt AC 9 ms 3564 KiB
one_digit_13.txt TLE 2205 ms 3148 KiB
one_digit_14.txt TLE 2205 ms 3340 KiB
one_digit_15.txt TLE 2205 ms 3300 KiB
one_digit_16.txt TLE 2205 ms 3204 KiB
random_01.txt WA 326 ms 3392 KiB
random_02.txt AC 3 ms 3584 KiB
random_03.txt WA 2 ms 3564 KiB
random_04.txt AC 6 ms 3560 KiB
random_05.txt WA 2 ms 3568 KiB
random_06.txt AC 2 ms 3464 KiB
random_07.txt AC 2 ms 3556 KiB
random_08.txt AC 2 ms 3388 KiB
random_09.txt AC 2 ms 3480 KiB
random_10.txt AC 2 ms 3564 KiB
random_11.txt WA 2 ms 3548 KiB
random_12.txt WA 2 ms 3472 KiB
random_13.txt TLE 2205 ms 3340 KiB
random_14.txt AC 1426 ms 3564 KiB
random_15.txt WA 587 ms 3588 KiB
random_16.txt WA 4 ms 3452 KiB
random_17.txt WA 2 ms 3452 KiB
random_18.txt WA 2 ms 3568 KiB
random_19.txt WA 2 ms 3556 KiB
random_20.txt WA 4 ms 3552 KiB
random_21.txt AC 3 ms 3524 KiB
random_22.txt WA 2 ms 3524 KiB
random_23.txt AC 2 ms 3480 KiB
random_24.txt WA 2 ms 3528 KiB
sample_01.txt AC 3 ms 3488 KiB
sample_02.txt AC 3 ms 3524 KiB
sample_03.txt TLE 2205 ms 3300 KiB