| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 490946 | kawaii | Multiply (CEOI17_mul) | C++17 | 70 ms | 131076 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
string n, m;
int a, b;
string add(string a, string b){
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
a.push_back('0'); b.push_back('0');
while(a.size() > b.size()) b.push_back('0');
while(a.size() < b.size()) a.push_back('0');
int cnt = 0, du = 0;
string res = "";
for(int i = 0; i < a.size(); i++){
cnt = a[i] + b[i] - 96 + du;
du = cnt / 10;
res.push_back(char(cnt % 10 + 48));
}
while(res.back() == '0') res.pop_back();
reverse(res.begin(), res.end());
return res;
}
string chia(string a){
string res = "";
int p = 0;
for(int i = 0; i < a.size(); i++){
p = p * 10 + a[i] - 48;
if(p >= 2){
res.push_back(char(p / 2 + 48));
p %= 2;
}
else res.push_back('0');
}
reverse(res.begin(), res.end());
while(res.back() == '0') res.pop_back();
reverse(res.begin(), res.end());
return res;
}
string nhan(string a, string b){
if(b == "1") return a;
string ans = nhan(a, chia(b));
//cout << a <<" "<< chia(b) << "\n";
if(b.back() % 2 == 0) return add(ans, ans);
else return add(add(ans, ans), a);
}
void solve(){
cout << nhan(n, m);
}
signed main(){
ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
cin >> a >> b >> n >> m;
solve();
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
