답안 #79957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
79957 2018-10-17T16:25:08 Z pzdba Uzastopni (COCI17_uzastopni) C++14
80 / 80
20 ms 664 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	LL n;
	scanf("%lld", &n);
	for(LL i=2;i<=min(n, (LL)200000);i++){
		LL lo = 1, hi = (n+i-1)/i;
		LL ans = -1;
		while(lo <= hi){
			LL mid = (lo+hi)/2;

			LL st = mid, en = mid+i-1;
			LL le = en-st+1;

			LL val = (st+en)*le/2;
			if(val <= n){
				if(val == n) ans = mid;
				lo = mid+1;
			}
			else hi = mid-1;
		}
		if(ans != -1){
			printf("%lld %lld\n", ans, ans+i-1);
		}
	}
}

Compilation message

uzastopni.cpp: In function 'int main()':
uzastopni.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 392 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 4 ms 552 KB Output is correct
5 Correct 6 ms 552 KB Output is correct
6 Correct 8 ms 552 KB Output is correct
7 Correct 9 ms 636 KB Output is correct
8 Correct 11 ms 636 KB Output is correct
9 Correct 14 ms 636 KB Output is correct
10 Correct 20 ms 664 KB Output is correct