http://oj.ecustacm.cn/problem.php?id=1386
通过海伦公式计算,答案为8.795
http://oj.ecustacm.cn/problem.php?id=1387
暴力枚举
#include <iostream> #include<algorithm> #include<cstdio> #include<vector> #include<queue> #include<stack> #include<cstring> #include<cmath> //#include<unordered_map> using namespace std; int ans; int main(){ for(int n=130;;n++){ int cnt=0; for(int a=1;a*a*2<=n;a++){//规定b大等于a int b=sqrt(n-a*a); if(b*b+a*a==n) cnt++; } if(cnt>=12){ ans=n; cout<<ans; break; } } return 0; } // freopen("testdata.in", "r", stdin);
http://oj.ecustacm.cn/problem.php?id=1388
递推解决
#include <iostream> #include<algorithm> #include<cstdio> #include<vector> #include<queue> #include<stack> #include<cstring> //#include<unordered_map> using namespace std; int n,k; int fun(int n,int k){ if(n==0) return 0; return (fun(n-1,k)+k)%n; } int main(){ cin>>n>>k; cout<<fun(n,k)+1; return 0; } // freopen("testdata.in", "r", stdin);