# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
222532 | dwsc | Popcount (COCI19_popcount) | C++14 | 18 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
string add(string s1,string s2){
vector<int> v;
int carry = 0;
if (s1.length() < s2.length()) swap(s1,s2);
while (s1.length() > s2.length()) s2 = "0"+s2;
for (int i = s1.length()-1; i >= 0; i--){
int v1 = s1[i]-48,v2 = s2[i]-48;
v.push_back((v1+v2+carry)%10);
carry = (v1+v2+carry)>=10;
}
if (carry) v.push_back(carry);
string s = "";
for (int i = v.size()-1; i >= 0; i--) s +=(char)(v[i]+48);
return s;
}
int main(){
int n,k;
cin >> n >> k;
int numboxes = n,boxsize = 1;
int val = 0,tempn = n;
while (tempn != 1){
val++;
tempn = (tempn+1)/2;
}
cout << val << "\n";
while (numboxes != 1){
string bigbox = "0",smallbox = "0";
int addto = 0;
int num = 0;
int bigval = 0,smallval = 0;
string counter = "1";
for (int i = 0; i < n; i++){
num++;
if (num > boxsize){
num-=boxsize;
addto = 1-addto;
}
if (addto){
bigbox = add(bigbox,counter);
}
else{
smallbox = add(smallbox,counter);
}
//cout << bigbox << " " << smallbox << "\n";
counter = add(counter,counter);
//cout << counter << "hi\n";
}
string finalstring = "A=(((A&"+bigbox+")>>"+to_string(boxsize)+")+(A&"+smallbox+"))";
assert(finalstring.length() <= 1000);
cout << finalstring << "\n";
numboxes = (numboxes+1)/2;
boxsize *= 2;
}
}
컴파일 시 표준 에러 (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... |