cin关闭同步后和scanf到底谁快,有时cin快,有时scanf快,请问各位大牛能否解释说明一下
#include
#include
#include
const double pi=acos(-1);
typedef unsigned long long ull;
using namespace std;
int main() {
int t;
scanf("%d",&t);
//ios::sync_with_stdio(false);
//cin>>t;
while (t--) {
ull n,x=1;
scanf("%llu",&n);
//cin>>n;
if(n>1)
x=ull(log(sqrt(2*pi*n))/log(8)+n*log(n/exp(1))/log(8)+1);
printf("%llu\n",x);
}
return 0;
}
这里就是关闭同步也超时,但有时用关闭同步的cin打表速度比scanf都快