JOI2006年模擬試験1 問題1@C++(88)
zatorikuとかに負けてられないのでがんばってプログラミング練習する。
#include <cstdio> #include <algorithm> using namespace std; int main(int argc,char* argv[]) { int a,b,c; int count_all=0; int count_right=0; int count_less=0; int count_more=0; while(true) { scanf("%d %d %d\n",&a,&b,&c); if(a<b) swap(a,b); if(b<c) swap(b,c); if(a<b) swap(a,b); if(a>=b+c) break; count_all++; int d=a*a-b*b-c*c; if(d>0) { count_more++; } else if(d==0) { count_right++; } else { count_less++; } } printf("%d %d %d %d\n",count_all,count_right,count_less,count_more); return 0; }
眠い。