답안 #337969

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337969 2020-12-22T08:07:35 Z amunduzbaev 홀-짝 수열 (IZhO11_oddeven) C++14
0 / 100
2000 ms 516 KB
/** made by amunduzbaev **/
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long 
#define ld long double 
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vll vector<ll>
#define vii vector<int>
const int N = 305;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
ll n, m, lsz, k, last, szz, timer;
bool ok;

int sss(ll last){ 
	ll res = 0; 
	while(last){ res++, last /= 10; } 
	return res; 
}

void fun(ll prev, ll nw){
	while(prev < nw){
		szz += sss(prev);
		prev += 2;
	}
}

void solve(){
	fastios 
	cin>>n;
	ll i=2;
	last = 1, szz = 1;
	ll prevl = 0;
	while(szz < n){
		prevl = last;
		last += (i*2)-1;
		szz += i;
		i++;
	}
	if(szz == n) cout<<last%10<<endl;
	else{
		for(;szz > n && prevl < last; last -= 2) szz --;
		cout<<last<<endl;
	}
	return;
}

int main(){
	fastios
	int t = 1;
	if(t) solve();
	else {
		cin>>t;
		while (t--) solve();
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 4 ms 364 KB Output is correct
8 Correct 12 ms 364 KB Output is correct
9 Correct 20 ms 364 KB Output is correct
10 Correct 100 ms 364 KB Output is correct
11 Correct 361 ms 492 KB Output is correct
12 Correct 587 ms 516 KB Output is correct
13 Execution timed out 2075 ms 364 KB Time limit exceeded
14 Halted 0 ms 0 KB -