답안 #36286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
36286 2017-12-07T05:14:53 Z Kerim 홀-짝 수열 (IZhO11_oddeven) C++14
0 / 100
0 ms 2028 KB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    //~ freopen("file.in", "r", stdin);
    ll n;
    scanf("%lld",&n);
	if(n==1){
		puts("1");
		return 0;
	}
	int BLOK=sqrt(n);
	for(int i=BLOK;i>=0;i--)
		if(i*1LL*(i+1)/2LL+(i+1)<n){
			ll ans=i*1LL*(i+1)+(i+1);
			n-=i*1LL*(i+1)/2LL+(i+1);
			if(n==1){
				printf("%lld\n",ans+1);
				return 0;
			}n--;ans++;
			printf("%lld\n",ans+n*2LL);
			break;
		}
	return 0;
}

Compilation message

oddeven.cpp: In function 'int main()':
oddeven.cpp:23:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2028 KB Output is correct
2 Correct 0 ms 2028 KB Output is correct
3 Incorrect 0 ms 2028 KB Output isn't correct
4 Halted 0 ms 0 KB -