#include<iostream> #include<cstdio> #include<cmath> #define ll long long using namespace std; int main() { int t; scanf("%d",&t); for(int k=1;k<=t;k++) { ll n; scanf("%lld",&n); ll ans=n-(ll)sqrt((double)n)-(ll)sqrt((double)n/2); printf("Case %d: %lld\n",k,ans); } return 0; }
做了半天都是超时,一直在想怎么用位运算减少时间,最后无奈看答案,发现居然有公式!!!
数论的题目好多都是套格式,知道公式一步到位,不知道想到死都想不出来
原文:http://www.cnblogs.com/acjiumeng/p/6502597.html