#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
long long mod_ans, mod, n, div, temp, m;
string arbitrary;
vector <long long> div_ans;
char sign;
while(cin >> arbitrary >> sign >> n){
int l = arbitrary.size();
mod = 0;
m = 0;
for(int i = 0; i < l; i++){
temp = (mod * 10) + (arbitrary[i]-48);
mod = ((mod * 10) + (arbitrary[i]-48)) % n; mod_ans = mod;
if(m == 1 && temp < n)div_ans.push_back(0);
if(temp >= n){
div = temp / n;div_ans.push_back(div);
m = 1;
}
}
if(sign == '/' && m == 1){
int z = div_ans.size();
for(int i = 0; i < z; i++)cout << div_ans[i];
cout << endl;
}
else if(sign == '/' && m == 0)cout << 0 << endl;
else if(sign == '%')cout << mod_ans << endl;
div_ans.clear();
}
return 0;
}
#include <string>
#include <vector>
using namespace std;
int main(){
long long mod_ans, mod, n, div, temp, m;
string arbitrary;
vector <long long> div_ans;
char sign;
while(cin >> arbitrary >> sign >> n){
int l = arbitrary.size();
mod = 0;
m = 0;
for(int i = 0; i < l; i++){
temp = (mod * 10) + (arbitrary[i]-48);
mod = ((mod * 10) + (arbitrary[i]-48)) % n; mod_ans = mod;
if(m == 1 && temp < n)div_ans.push_back(0);
if(temp >= n){
div = temp / n;div_ans.push_back(div);
m = 1;
}
}
if(sign == '/' && m == 1){
int z = div_ans.size();
for(int i = 0; i < z; i++)cout << div_ans[i];
cout << endl;
}
else if(sign == '/' && m == 0)cout << 0 << endl;
else if(sign == '%')cout << mod_ans << endl;
div_ans.clear();
}
return 0;
}
No comments:
Post a Comment