2 solutions

  • 0
    @ 2023-11-23 22:44:54
    #include <stdio.h>
    int main()
    {
    	double sn = 0 * 1.0, d;
        int k, i = 1;
    	scanf("%d", &k);
    	while (sn <= k)
    	{
    		d = 1.0 / i;
    		sn += d;
    		i++;
    	}
    	printf("%d", i - 1);
    	return 0;
    }
    /*各位佬能不能看一下我为什么输出i - 1正确,输出i不正确*/
    

    Information

    ID
    6753
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    7
    Tags
    (None)
    # Submissions
    407
    Accepted
    79
    Uploaded By