Submission #486180


Source Code Expand

Copy
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}

//const int INF=5e8;

int L,s;

int sqrt(int a){
  int lb=0,ub=L;
  while(ub-lb>1){
    int md=(lb+ub)>>1;
    if(md*md>a) ub=md;
    else lb=md;
  }
  return lb;
}


int main(){
  cin>>L>>s;

  int res=0;
  REPN(i,L,s+1){
    int sum=i*i-s*s;
    for(int j=i-1;j>0;--j){//k<j<i
      int rest=sum-j*j;
      if(rest>j*j) break;

      int k=sqrt(rest);
      if(k*k==rest && i+j+k<=L && j+k>i && __gcd(j,__gcd(i,k))==1){
        ++res;
      }
    }
  }
  cout<<res<<endl;
	return 0;
}

Submission Info

Submission Time
Task D - ほぼピタゴラスの三角形
User hogloid
Language C++11 (GCC 4.9.2)
Score 60
Code Size 1472 Byte
Status
Exec Time 5041 ms
Memory 932 KB

Test Cases

Set Name Score / Max Score Test Cases
small 60 / 60 00_example_1.txt, 00_example_2.txt, 03_small_00.txt, 03_small_01.txt, 03_small_02.txt, 03_small_03.txt, 03_small_04.txt, 03_small_05.txt, 03_small_06.txt, 03_small_07.txt, 03_small_08.txt, 03_small_09.txt, 03_small_10.txt, 03_small_11.txt, 03_small_12.txt, 03_small_13.txt, 03_small_14.txt, 03_small_15.txt, 03_small_16.txt, 03_small_17.txt, 03_small_18.txt, 03_small_19.txt, 03_small_20.txt, 03_small_21.txt, 03_small_22.txt, 03_small_23.txt, 03_small_24.txt, 03_small_25.txt, 03_small_26.txt, 03_small_27.txt, 03_small_28.txt, 03_small_29.txt, 03_small_30.txt, 03_small_31.txt, 03_small_32.txt, 03_small_33.txt, 03_small_34.txt, 03_small_35.txt, 03_small_36.txt, 03_small_37.txt, 03_small_38.txt, 03_small_39.txt, 03_small_40.txt, 03_small_41.txt, 03_small_42.txt, 03_small_43.txt, 03_small_44.txt, 03_small_45.txt, 03_small_46.txt, 03_small_47.txt, 03_small_48.txt, 03_small_49.txt, 03_small_50.txt, 03_small_51.txt, 03_small_52.txt, 03_small_53.txt, 03_small_54.txt, 03_small_55.txt, 03_small_56.txt, 03_small_57.txt, 03_small_58.txt, 03_small_59.txt, 03_small_60.txt, 03_small_61.txt, 03_small_62.txt, 03_small_63.txt, 03_small_64.txt, 03_small_65.txt, 03_small_66.txt, 03_small_67.txt, 03_small_68.txt, 03_small_69.txt, 03_small_70.txt, 03_small_71.txt, 03_small_72.txt, 03_small_73.txt, 03_small_74.txt, 03_small_75.txt, 03_small_76.txt, 03_small_77.txt, 03_small_78.txt, 03_small_79.txt, 03_small_80.txt, 03_small_81.txt, 03_small_82.txt, 03_small_83.txt, 03_small_84.txt, 03_small_85.txt, 03_small_86.txt, 03_small_87.txt, 03_small_88.txt, 03_small_89.txt, 03_small_90.txt, 03_small_91.txt, 03_small_92.txt, 03_small_93.txt, 03_small_94.txt, 03_small_95.txt, 03_small_96.txt, 03_small_97.txt, 03_small_98.txt, 03_small_99.txt, 05_small_random_1.txt, 05_small_random_10.txt, 05_small_random_11.txt, 05_small_random_12.txt, 05_small_random_13.txt, 05_small_random_14.txt, 05_small_random_15.txt, 05_small_random_16.txt, 05_small_random_17.txt, 05_small_random_18.txt, 05_small_random_19.txt, 05_small_random_2.txt, 05_small_random_20.txt, 05_small_random_21.txt, 05_small_random_22.txt, 05_small_random_23.txt, 05_small_random_24.txt, 05_small_random_25.txt, 05_small_random_26.txt, 05_small_random_27.txt, 05_small_random_28.txt, 05_small_random_29.txt, 05_small_random_3.txt, 05_small_random_30.txt, 05_small_random_4.txt, 05_small_random_5.txt, 05_small_random_6.txt, 05_small_random_7.txt, 05_small_random_8.txt, 05_small_random_9.txt, 08_manual_0.txt, 08_manual_2.txt, 08_manual_3.txt
All 0 / 140 00_example_1.txt, 00_example_2.txt, 03_small_00.txt, 03_small_01.txt, 03_small_02.txt, 03_small_03.txt, 03_small_04.txt, 03_small_05.txt, 03_small_06.txt, 03_small_07.txt, 03_small_08.txt, 03_small_09.txt, 03_small_10.txt, 03_small_11.txt, 03_small_12.txt, 03_small_13.txt, 03_small_14.txt, 03_small_15.txt, 03_small_16.txt, 03_small_17.txt, 03_small_18.txt, 03_small_19.txt, 03_small_20.txt, 03_small_21.txt, 03_small_22.txt, 03_small_23.txt, 03_small_24.txt, 03_small_25.txt, 03_small_26.txt, 03_small_27.txt, 03_small_28.txt, 03_small_29.txt, 03_small_30.txt, 03_small_31.txt, 03_small_32.txt, 03_small_33.txt, 03_small_34.txt, 03_small_35.txt, 03_small_36.txt, 03_small_37.txt, 03_small_38.txt, 03_small_39.txt, 03_small_40.txt, 03_small_41.txt, 03_small_42.txt, 03_small_43.txt, 03_small_44.txt, 03_small_45.txt, 03_small_46.txt, 03_small_47.txt, 03_small_48.txt, 03_small_49.txt, 03_small_50.txt, 03_small_51.txt, 03_small_52.txt, 03_small_53.txt, 03_small_54.txt, 03_small_55.txt, 03_small_56.txt, 03_small_57.txt, 03_small_58.txt, 03_small_59.txt, 03_small_60.txt, 03_small_61.txt, 03_small_62.txt, 03_small_63.txt, 03_small_64.txt, 03_small_65.txt, 03_small_66.txt, 03_small_67.txt, 03_small_68.txt, 03_small_69.txt, 03_small_70.txt, 03_small_71.txt, 03_small_72.txt, 03_small_73.txt, 03_small_74.txt, 03_small_75.txt, 03_small_76.txt, 03_small_77.txt, 03_small_78.txt, 03_small_79.txt, 03_small_80.txt, 03_small_81.txt, 03_small_82.txt, 03_small_83.txt, 03_small_84.txt, 03_small_85.txt, 03_small_86.txt, 03_small_87.txt, 03_small_88.txt, 03_small_89.txt, 03_small_90.txt, 03_small_91.txt, 03_small_92.txt, 03_small_93.txt, 03_small_94.txt, 03_small_95.txt, 03_small_96.txt, 03_small_97.txt, 03_small_98.txt, 03_small_99.txt, 05_small_random_1.txt, 05_small_random_10.txt, 05_small_random_11.txt, 05_small_random_12.txt, 05_small_random_13.txt, 05_small_random_14.txt, 05_small_random_15.txt, 05_small_random_16.txt, 05_small_random_17.txt, 05_small_random_18.txt, 05_small_random_19.txt, 05_small_random_2.txt, 05_small_random_20.txt, 05_small_random_21.txt, 05_small_random_22.txt, 05_small_random_23.txt, 05_small_random_24.txt, 05_small_random_25.txt, 05_small_random_26.txt, 05_small_random_27.txt, 05_small_random_28.txt, 05_small_random_29.txt, 05_small_random_3.txt, 05_small_random_30.txt, 05_small_random_4.txt, 05_small_random_5.txt, 05_small_random_6.txt, 05_small_random_7.txt, 05_small_random_8.txt, 05_small_random_9.txt, 08_manual_0.txt, 08_manual_2.txt, 08_manual_3.txt, 10_max_01.txt, 10_max_02.txt, 10_max_03.txt, 10_max_04.txt, 10_max_05.txt, 10_max_06.txt, 10_max_07.txt, 10_max_08.txt, 10_max_09.txt, 10_max_10.txt, 10_max_41.txt, 10_max_42.txt, 10_max_43.txt, 10_max_44.txt, 10_max_45.txt, 10_max_46.txt, 10_max_47.txt, 10_max_48.txt, 10_max_49.txt, 10_max_50.txt, 11_large_00.txt, 11_large_01.txt, 11_large_02.txt, 11_large_03.txt, 11_large_04.txt, 11_large_05.txt, 11_large_06.txt, 11_large_07.txt, 11_large_08.txt, 11_large_09.txt, 20_manual_1.txt, 20_manual_10.txt, 20_manual_11.txt, 20_manual_12.txt, 20_manual_13.txt, 20_manual_4.txt, 20_manual_5.txt, 20_manual_6.txt, 20_manual_7.txt, 20_manual_8.txt, 20_manual_9.txt
Case Name Status Exec Time Memory
00_example_1.txt 27 ms 800 KB
00_example_2.txt 25 ms 920 KB
03_small_00.txt 27 ms 796 KB
03_small_01.txt 28 ms 792 KB
03_small_02.txt 33 ms 916 KB
03_small_03.txt 27 ms 788 KB
03_small_04.txt 26 ms 916 KB
03_small_05.txt 31 ms 920 KB
03_small_06.txt 26 ms 804 KB
03_small_07.txt 32 ms 796 KB
03_small_08.txt 26 ms 800 KB
03_small_09.txt 29 ms 744 KB
03_small_10.txt 29 ms 676 KB
03_small_11.txt 26 ms 920 KB
03_small_12.txt 25 ms 920 KB
03_small_13.txt 31 ms 796 KB
03_small_14.txt 30 ms 924 KB
03_small_15.txt 29 ms 708 KB
03_small_16.txt 32 ms 808 KB
03_small_17.txt 32 ms 676 KB
03_small_18.txt 27 ms 916 KB
03_small_19.txt 28 ms 788 KB
03_small_20.txt 30 ms 916 KB
03_small_21.txt 29 ms 796 KB
03_small_22.txt 31 ms 920 KB
03_small_23.txt 32 ms 920 KB
03_small_24.txt 31 ms 920 KB
03_small_25.txt 30 ms 920 KB
03_small_26.txt 24 ms 920 KB
03_small_27.txt 32 ms 792 KB
03_small_28.txt 30 ms 796 KB
03_small_29.txt 25 ms 800 KB
03_small_30.txt 29 ms 920 KB
03_small_31.txt 34 ms 756 KB
03_small_32.txt 26 ms 924 KB
03_small_33.txt 31 ms 800 KB
03_small_34.txt 33 ms 712 KB
03_small_35.txt 32 ms 916 KB
03_small_36.txt 30 ms 800 KB
03_small_37.txt 32 ms 916 KB
03_small_38.txt 28 ms 672 KB
03_small_39.txt 28 ms 748 KB
03_small_40.txt 29 ms 796 KB
03_small_41.txt 29 ms 796 KB
03_small_42.txt 34 ms 668 KB
03_small_43.txt 30 ms 920 KB
03_small_44.txt 26 ms 924 KB
03_small_45.txt 36 ms 672 KB
03_small_46.txt 32 ms 800 KB
03_small_47.txt 30 ms 800 KB
03_small_48.txt 28 ms 800 KB
03_small_49.txt 27 ms 916 KB
03_small_50.txt 27 ms 796 KB
03_small_51.txt 33 ms 796 KB
03_small_52.txt 28 ms 804 KB
03_small_53.txt 29 ms 792 KB
03_small_54.txt 33 ms 788 KB
03_small_55.txt 31 ms 792 KB
03_small_56.txt 27 ms 800 KB
03_small_57.txt 28 ms 804 KB
03_small_58.txt 28 ms 800 KB
03_small_59.txt 36 ms 736 KB
03_small_60.txt 31 ms 800 KB
03_small_61.txt 30 ms 800 KB
03_small_62.txt 27 ms 676 KB
03_small_63.txt 30 ms 800 KB
03_small_64.txt 26 ms 804 KB
03_small_65.txt 28 ms 804 KB
03_small_66.txt 26 ms 804 KB
03_small_67.txt 30 ms 764 KB
03_small_68.txt 27 ms 808 KB
03_small_69.txt 35 ms 728 KB
03_small_70.txt 26 ms 672 KB
03_small_71.txt 30 ms 808 KB
03_small_72.txt 27 ms 696 KB
03_small_73.txt 29 ms 796 KB
03_small_74.txt 34 ms 672 KB
03_small_75.txt 33 ms 924 KB
03_small_76.txt 28 ms 800 KB
03_small_77.txt 24 ms 744 KB
03_small_78.txt 26 ms 800 KB
03_small_79.txt 32 ms 808 KB
03_small_80.txt 30 ms 920 KB
03_small_81.txt 32 ms 700 KB
03_small_82.txt 26 ms 924 KB
03_small_83.txt 26 ms 804 KB
03_small_84.txt 27 ms 800 KB
03_small_85.txt 29 ms 924 KB
03_small_86.txt 31 ms 800 KB
03_small_87.txt 26 ms 796 KB
03_small_88.txt 24 ms 804 KB
03_small_89.txt 29 ms 804 KB
03_small_90.txt 32 ms 676 KB
03_small_91.txt 32 ms 804 KB
03_small_92.txt 28 ms 800 KB
03_small_93.txt 30 ms 804 KB
03_small_94.txt 26 ms 800 KB
03_small_95.txt 31 ms 672 KB
03_small_96.txt 29 ms 800 KB
03_small_97.txt 28 ms 700 KB
03_small_98.txt 30 ms 804 KB
03_small_99.txt 27 ms 804 KB
05_small_random_1.txt 50 ms 800 KB
05_small_random_10.txt 58 ms 808 KB
05_small_random_11.txt 70 ms 672 KB
05_small_random_12.txt 1097 ms 804 KB
05_small_random_13.txt 179 ms 796 KB
05_small_random_14.txt 543 ms 808 KB
05_small_random_15.txt 469 ms 796 KB
05_small_random_16.txt 687 ms 916 KB
05_small_random_17.txt 907 ms 792 KB
05_small_random_18.txt 518 ms 800 KB
05_small_random_19.txt 510 ms 800 KB
05_small_random_2.txt 41 ms 740 KB
05_small_random_20.txt 76 ms 800 KB
05_small_random_21.txt 1090 ms 800 KB
05_small_random_22.txt 846 ms 796 KB
05_small_random_23.txt 282 ms 800 KB
05_small_random_24.txt 479 ms 800 KB
05_small_random_25.txt 547 ms 792 KB
05_small_random_26.txt 106 ms 796 KB
05_small_random_27.txt 29 ms 804 KB
05_small_random_28.txt 364 ms 804 KB
05_small_random_29.txt 777 ms 804 KB
05_small_random_3.txt 323 ms 924 KB
05_small_random_30.txt 252 ms 800 KB
05_small_random_4.txt 959 ms 804 KB
05_small_random_5.txt 394 ms 800 KB
05_small_random_6.txt 149 ms 800 KB
05_small_random_7.txt 107 ms 804 KB
05_small_random_8.txt 533 ms 800 KB
05_small_random_9.txt 420 ms 808 KB
08_manual_0.txt 1117 ms 800 KB
08_manual_2.txt 33 ms 796 KB
08_manual_3.txt 1118 ms 808 KB
10_max_01.txt 5035 ms 800 KB
10_max_02.txt 5036 ms 804 KB
10_max_03.txt 5035 ms 920 KB
10_max_04.txt 5034 ms 804 KB
10_max_05.txt 5032 ms 932 KB
10_max_06.txt 5034 ms 808 KB
10_max_07.txt 5034 ms 796 KB
10_max_08.txt 5038 ms 892 KB
10_max_09.txt 5033 ms 920 KB
10_max_10.txt 5034 ms 800 KB
10_max_41.txt 5033 ms 800 KB
10_max_42.txt 5034 ms 808 KB
10_max_43.txt 5034 ms 928 KB
10_max_44.txt 5035 ms 804 KB
10_max_45.txt 5034 ms 808 KB
10_max_46.txt 5034 ms 800 KB
10_max_47.txt 5035 ms 924 KB
10_max_48.txt 5033 ms 932 KB
10_max_49.txt 5033 ms 808 KB
10_max_50.txt 5038 ms 808 KB
11_large_00.txt 5034 ms 808 KB
11_large_01.txt 5035 ms 928 KB
11_large_02.txt 5034 ms 808 KB
11_large_03.txt 5032 ms 800 KB
11_large_04.txt 5038 ms 840 KB
11_large_05.txt 5034 ms 804 KB
11_large_06.txt 5033 ms 924 KB
11_large_07.txt 5034 ms 796 KB
11_large_08.txt 5034 ms 812 KB
11_large_09.txt 5035 ms 844 KB
20_manual_1.txt 5035 ms 872 KB
20_manual_10.txt 5034 ms 852 KB
20_manual_11.txt 5035 ms 800 KB
20_manual_12.txt 5035 ms 860 KB
20_manual_13.txt 5035 ms 796 KB
20_manual_4.txt 5041 ms 872 KB
20_manual_5.txt 5033 ms 804 KB
20_manual_6.txt 5034 ms 792 KB
20_manual_7.txt 5035 ms 920 KB
20_manual_8.txt 5034 ms 800 KB
20_manual_9.txt 5032 ms 800 KB