1 solutions

  • 0
    @ 2025-11-5 17:55:52

    C :

    #include<stdio.h>
    #include<math.h>
    int main()
    {
    	int t,n;
    	double a;
    	scanf("%d",&t);
    	while(t--)
    	{
    		scanf("%lf",&a);
    		n=1;
    		if(a<=10){printf("1\n");continue;}
    		while(a>=10)
    		{
    			a+=5;
    			a/=10;
    			a=floor(a);
    			n*=10;
    		}
    		printf("%d\n",(int)(a*n));
    	}
    	return 0;
    }
    

    C++ :

    #include <stdio.h>
    
    int main() {
    	int t, n, k;
    	scanf("%d", &t);
    	while (t--) {
    		scanf("%d", &n);
    		if (n <= 10) {
    			puts("1");
    			continue;
    		}
    		k = 1;
    		while (1) {
    			k *= 10;
    			if (k > n)
    				break;
    			if (n % k >= k / 2)
    				n = (n / k + 1) * k;
    			else
    				n = n / k * k;
    		}
    		printf("%d\n", n);
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    18651
    Time
    1000ms
    Memory
    32MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By