Submission #00025


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll x, p;
cin >> x >> p;
ll ans = 0;
while(x > 0){
ll d = 1;
while(true){
d *= p;
if(x < d){
d /= p;
break;
}
}
ll div = x/d;
ans += div;
x -= d*div;
}
cout << ans << endl;
return 0;
}

ステータス

項目 データ
問題 0003 - おもり
ユーザー名 solooon
投稿日時 2016-11-11 17:57:23
言語 C++11
状態 Time Limit Exceeded
得点 0
ソースコード長 837 Byte
最大実行時間 1000 ms
最大メモリ使用量 564 KB

セット

セット 得点 Cases
1 ALL 0 / 100 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
00.in AC 19 ms 480 KB
1
01.in AC 20 ms 444 KB
1
02.in AC 13 ms 536 KB
1
03.in AC 16 ms 504 KB
1
04.in AC 15 ms 472 KB
1
05.in TLE 1000 ms 564 KB
1