#include<bits/stdc++.h>
using namespace std;

long long a[110];

bool f(int i,int l,int r)
{
	if(l+r > i)
	{
		return false;
	}
	else if(i == (l+r)*(l-r))
	{
		return true;
	}
	else if(l <= r+1)
	{
		f(i,l+1,r);
	}
	else
	{
		f(i,l,r+1);
	}
}	

int main()
{
	int n;
	cin >> n;
	int i = 1;
	int j = 0;
	while(true)
	{
		if(j == n)
		{
			cout << a[n-1] << endl;
			return 0;	
		}	
		if(f(i,2,1) == true)
		{
			a[j] = i;
			j++;	
		}
		i++;
	}
	
	
	return 0;
}

#include<bits/stdc++.h>
#include<set>
using namespace std;

set<int> a;

int main()
{
	int n;
	cin >> n;
	for(int i = 2;;i++)
	{
		for(int j = 1; j < i; j++)
		{
			a.insert(i*i - j*j);
			if(a.size() == 101)
			{
				goto FLAG;
			}
		}
	}
	FLAG:
	int cnt = 0;
	for(set<int>::iterator it = a.begin(); it != a.end(); it++)
	{
		cnt++;
		if(cnt == n)
		{
			cout << *it << endl;
			break;
		}
	}
	
	return 0;
}

1 comments

  • @ 2024-1-7 18:29:58
    #include<bits/stdc++.h>
    #include<map>
    #include<ctime>
    #include<string>
    using namespace std;
    int a[150]={3,5,7,8,9,11,12,13,15,16,17,19,20,21,23,24,25,27,28,29,31,32,33,35,36,37,39,40,41,43,44,45,47,48,49,51,52,53,55,56,57,59,60,61,63,64,65,67,68,69,71,72,73,75,76,77,79,80,81,83,84,85,87,88,89,91,92,93,95,96,97,99,100,101,103,104,105,107,108,109,111,112,113,115,116,117,119,120,121,123,124,125,127,128,129,131,132,133,135,136,137,139,140,141,143,144,145,147,148,149,151,152,153,155,156,157,159,160}; 
    int main()
    {
    	int n;
    	cin>>n;
    	cout<<a[n-1]<<endl;
    	return 0;
     }
    
    • 1

    Information

    ID
    929
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    # Submissions
    68
    Accepted
    16
    Uploaded By