Skip to content

Instantly share code, notes, and snippets.

@WindAzure
Last active August 26, 2018 05:08
Show Gist options
  • Save WindAzure/570443368cbd881786744bae47a9a508 to your computer and use it in GitHub Desktop.
Save WindAzure/570443368cbd881786744bae47a9a508 to your computer and use it in GitHub Desktop.
algorithm exercise
#include <stdio.h>
int main()
{
auto T = 1;
auto n = 0, m = 0;
while (~scanf("%d%d", &n, &m))
{
if (n == 0 && m == 0)
{
break;
}
auto sum = 0.0;
for (auto num = n; num <= m; num++)
{
auto reciprocal = 1.0 / num / num;
sum += reciprocal;
}
printf("Case %d: %.5lf\n", T, sum);
T++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment