Submission #30016698


Source Code Expand

#include<stdio.h>
#include<math.h>
#define ll long long

ll isqrt(ll N){
	ll sqrtN=sqrt(N)-1;
	while(sqrtN+1<=N/(sqrtN+1))sqrtN++;
	return sqrtN;
}

ll dp[100010];
ll dpsum[100010];

int main(){
	dp[1]=1;
	dpsum[1]=1;
	
	for(int i=2;i<=100000;i++){
		dp[i]=dpsum[isqrt(i)];
		dpsum[i]=dpsum[i-1]+dp[i];
	}
	
	int t;
	scanf("%d",&t);
	while(t--){
		ll x;
		scanf("%lld",&x);
		ll x2=isqrt(x);
		ll x4=isqrt(x2);
		ll ans=0;
		for(ll i=1;i<=x4;i++)ans+=(x2-i*i+1)*dp[i];
		printf("%lld\n",ans);
	}
}

Submission Info

Submission Time
Task G - Sqrt
User kyopro_friends
Language C (GCC 9.2.1)
Score 600
Code Size 532 Byte
Status AC
Exec Time 10 ms
Memory 3680 KiB

Compile Error

./Main.c: In function ‘main’:
./Main.c:24:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   24 |  scanf("%d",&t);
      |  ^~~~~~~~~~~~~~
./Main.c:27:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   27 |   scanf("%lld",&x);
      |   ^~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 1
AC × 23
Set Name Test Cases
Sample sample_01.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt
Case Name Status Exec Time Memory
random_01.txt AC 7 ms 3572 KiB
random_02.txt AC 7 ms 3656 KiB
random_03.txt AC 6 ms 3608 KiB
random_04.txt AC 7 ms 3660 KiB
random_05.txt AC 5 ms 3556 KiB
random_06.txt AC 9 ms 3656 KiB
random_07.txt AC 7 ms 3680 KiB
random_08.txt AC 8 ms 3656 KiB
random_09.txt AC 7 ms 3676 KiB
random_10.txt AC 10 ms 3676 KiB
random_11.txt AC 10 ms 3652 KiB
random_12.txt AC 9 ms 3652 KiB
random_13.txt AC 6 ms 3584 KiB
random_14.txt AC 7 ms 3660 KiB
random_15.txt AC 8 ms 3568 KiB
random_16.txt AC 8 ms 3612 KiB
random_17.txt AC 9 ms 3588 KiB
random_18.txt AC 7 ms 3656 KiB
random_19.txt AC 7 ms 3652 KiB
random_20.txt AC 9 ms 3568 KiB
random_21.txt AC 6 ms 3564 KiB
random_22.txt AC 6 ms 3676 KiB
sample_01.txt AC 6 ms 3612 KiB