# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
337844 | 2020-12-22T02:58:44 Z | beksultan04 | 홀-짝 수열 (IZhO11_oddeven) | C++14 | 0 ms | 364 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define OK puts("OK"); #define NO puts("NO"); #define YES puts("YES"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define allr(s) s.rbegin(),s.rend() #define pb push_back #define sz(v) (int)v.size() #define endi puts(""); const int N = 1e6+12,INF=1e9+7; int n; bool is(int x){ x = (x*(x+1))/2; ret x >= n; } main(){ int i,c=1,cnt=0,l=1,r=100; scan1(n) while (r-l>1){ int m = l+r>>1; if (is(m))r=m; else l=m; } if (is(r))l=r; c = l*l; cnt = r*(r+1)>>1; c -= (cnt-n)*2; cout <<c; } /* 1-1 2-2 4 3-5 7 9 4-10 12 14 16 5-17 19 21 23 25 6-26 28 30 32 34 36 7-37 39 41 43 45 47 49 8-50 52 54 56 58 60 62 64 9-65 67 69 71 73 75 77 79 81 10-82 84 86 88 90 92 94 96 98 100 11-101 103 105 107 109 111 113 115 117 119 121 12-122 124 126 128 130 132 134 136 138 140 142 144 13-145 147 149 151 153 155 157 159 161 163 165 167 169 14-170 172 174 176 178 180 182 184 186 188 190 192 194 196 15-197 199 201 203 205 207 209 211 213 215 217 219 221 223 225 16-226 228 230 232 234 236 238 240 242 244 246 248 250 252 254 256 17-257 259 261 263 265 267 269 271 273 275 277 279 281 283 285 287 289 18-290 292 294 296 298 300 302 304 306 308 310 312 314 316 318 320 322 324 19-325 327 329 331 333 335 337 339 341 343 345 347 349 351 353 355 357 359 361 20-362 364 366 368 370 372 374 376 378 380 382 384 386 388 390 392 394 396 398 400*/
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |