Skip to content

Instantly share code, notes, and snippets.

@yswallow
Last active December 16, 2015 18:09
Show Gist options
  • Select an option

  • Save yswallow/5475609 to your computer and use it in GitHub Desktop.

Select an option

Save yswallow/5475609 to your computer and use it in GitHub Desktop.
http://www.titech.ac.jp/publications/j/techtech17/06.html のNo.2 (C言語) 人力で解くアルゴリズムを考えさせる問題だと思うけど。
#include <stdio.h>
int main(void)
{
int i,t,sum;
for(i=1;i<250;i++)
{
sum = 0;
for(t=i;sum<500;t++)
{
sum += t;
if(sum==500)
{
printf("%d\n",i);
break;
}
}
}
return 0;
}
//=> 8,59,98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment