这一场…心情复杂
比赛结果:
比赛过程:
没错,这一场没有传统的签到题,没有www…
开局1h,看着奇怪的榜单,除了前两页,后面队伍仍在爆零状态。此时wmd手上敲着F,cqf想着当时最多人过的J,我在看只有10来个人过的E(math),然后第一发F wa了,再调整了大半小时后终于迎来了本场第一发AC。半小时后cqf切了J。彼时,我推了快一个小时公式总于是把E如何求得答案数搞出来了,然后开始加速优化代码过程,(期间还因为一些语法问题搞得全队集体懵逼,原来set的迭代器不能直接加减啊啊 )最后加速到了一个合适的地步,交了一发,AC了。后2.5h本以为还能在开至少议题,但是策略再一次出问题,cqf写了很久的B,我一直在看C,有了一个构造的办法但最后20min才碰键盘开始敲,并且只剩十分钟时突然想到二分图匹配但是没有与队友说起(失大策),都导致了我过完E后全队直接罚坐到结束。日后还是要多加注意策略问题啊www
TE math
样例输入:
10
10
100
1000
10000
100000
114514
1919810
20190104
123123123123
10000001000000
样例输出:
2
5
14
31
65
67
158
326
5226
22091
题意:给定n,问满足1<=x<=y<=n的所有二元数对(x,y),有几个满足(x*y+1)可以整除(x ^ 2 + y ^ 2)
(不是按官方题解来写的 详细的解释明天再补)
Accode:
#pragma GCC optimize(s)
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<vector>
#include<algorithm>
#define LL long long
using namespace std;
LL n,t,ans,temp;
__int128 N = 1000000000000000000;
vector<LL> v;
inline __int128 read()
{
__int128 x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
void init()
{
__int128 f[4];
for(__int128 i=2;i*i*i*i*i-i<=N;i++)
{
f[1] = i;
f[2] = i*i*i;
while( 1 )
{
f[3] = i*i*f[2] - f[1];
if( f[3] <= N )
{
v.push_back( f[3] );
}
else break;
f[1] = f[2];
f[2] = f[3];
}
}
sort(v.begin(),v.end());
}
int main()
{
init();
//freopen("out2.txt","r",stdin);
//freopen("outE.txt","w",stdout);
cin>>t;
while( t-- )
{
map<int,int> ma;
ans = 0;
scanf("%lld",&n);
temp = pow( n,1.0/3.0 );
temp -= 2;
if( temp * temp * temp <= n )
{
while( temp * temp * temp <= n )
{
temp++;
}
temp--;
}
ans = temp;
ans += (LL)(upper_bound( v.begin() , v.end() , n ) - v.begin());
// cout<<(it - s.begin());
printf("%lld\n",ans);
}
return 0;
}