Submission #992234
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;
#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}
#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())
template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}
ll m,n;
int main(){
int i,j,k;
cin >> n;
ll result=0;
ll l,h,c,d,nn;
nn=n;
while (result != n){
l = 1;
h = nn;
while (l+1<h){
c = (l + h) / 2;
d = c*(c+1)/2+result;
if (d<n){
l = c;
}else if (d > n){
h = c;
}else{
l = h = c;
break;
}
}
if (l*(l+1)/2+result < n){
printf("%lld\n",h);
result+=h;
nn=h;
}else {
printf("%lld\n",l);
result+=l;
nn=l;
}
}
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Exactly N points |
User |
m_buyoh |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1787 Byte |
Status |
AC |
Exec Time |
3 ms |
Memory |
256 KB |
Judge Result
Set Name |
sample |
dataset1 |
dataset2 |
Score / Max Score |
0 / 0 |
200 / 200 |
100 / 100 |
Status |
|
|
|
Set Name |
Test Cases |
sample |
sample-01.txt, sample-02.txt, sample-03.txt |
dataset1 |
sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt |
dataset2 |
sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt |
Case Name |
Status |
Exec Time |
Memory |
01-01.txt |
AC |
3 ms |
256 KB |
01-02.txt |
AC |
3 ms |
256 KB |
01-03.txt |
AC |
3 ms |
256 KB |
01-04.txt |
AC |
3 ms |
256 KB |
01-05.txt |
AC |
3 ms |
256 KB |
01-06.txt |
AC |
3 ms |
256 KB |
01-07.txt |
AC |
3 ms |
256 KB |
01-08.txt |
AC |
3 ms |
256 KB |
01-09.txt |
AC |
3 ms |
256 KB |
01-10.txt |
AC |
3 ms |
256 KB |
02-01.txt |
AC |
3 ms |
256 KB |
02-02.txt |
AC |
3 ms |
256 KB |
02-03.txt |
AC |
3 ms |
256 KB |
02-04.txt |
AC |
3 ms |
256 KB |
02-05.txt |
AC |
3 ms |
256 KB |
02-06.txt |
AC |
3 ms |
256 KB |
02-07.txt |
AC |
3 ms |
256 KB |
02-08.txt |
AC |
3 ms |
256 KB |
sample-01.txt |
AC |
3 ms |
256 KB |
sample-02.txt |
AC |
3 ms |
256 KB |
sample-03.txt |
AC |
3 ms |
256 KB |