#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef priority_queue<pi,vector<pi>,greater<pi>> djk;
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a));
#define maxE(a) *max_element(a, a+sizeof(a)/sizeof(a[0]))
int main(){
cin.tie(0)->sync_with_stdio(0);
string s;
cin >> s;
int dot = 0;
int k = s.length()-1;
bool good = false;
while (s[k] != '.'){
if (s[k] != '0' || good){
dot++;
good = true;
}
k--;
}
//cout << dot << endl;
ll j = 1;
ll num = 0;
good = false;
for (int i = (int)s.length()-1; i >= 0; i--){
if (i == k){continue;}
if (s[i] != '0' || good){
num += (s[i]-'0')*j;
j*=10;
good = true;
}
}
//cout << num << endl;
ll div = (ll)pow(10, dot);
good = false;
ll times = 1;
ll numT = num;
while (num % div != 0){
int n = num%10;
if (n != 0 && n % 2 == 0){
times *= 5;
num *= 5;
good = true;
} else if (n == 5){
times *= 2;
num *= 2;
good = true;
} else if (n != 0){
times *= 10;
num *= 10;
good = true;
} else if (good){
num *= 10;
times *= 10;
}
}
//cout << times << endl;
numT *= times;
numT /= div;
//cout << numT << endl;
ll arr[6];
ms(arr, 0);
int base = numT/times;
ll a = numT%times;
arr[base] = times-a;
arr[base+1] = a;
for (int i = 1; i <= 5; i++){
cout << arr[i] << ((i != 5)?" ":"");
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1088 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |