題目
題解:
因此c=(a*a-1)/2+1
我們暴力列舉a,從a=1到(a * a-1)/2+1<=n (C需要<=n)
如果滿足(a * a-1)%2==0,即b為整數,且c=b+1,C也為整數,符合條件,貢獻+1
Code:
#include<iostream>
#include<cmath>
#define pii pair<int,int>
#define FAST ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
int main()
{
FAST;
int t;cin >> t;
while (t--)
{
ll n;cin >> n;
int sum = 0;
for (ll i = 1;((i * i) - 1) / 2 + 1 <= n;i++)
{
ll b = i * i - 1;
if (b % 2 == 0 && b >= i) sum++;
}
cout << sum << endl;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/260286.html
標籤:其他
下一篇:GStreamer 安卓安裝輔導四:這個播放器不好吃,塞牙縫,來根 ViewModel 牌牙簽,將 GStreamer 剔出來。
