首页 > 代码库 > Codeforces 450(#257 (Div. 2) ) 解题报告

Codeforces 450(#257 (Div. 2) ) 解题报告

A:

 1 // File Name: a.cpp 2 // Author: darkdream 3 // Created Time: 2014年07月19日 星期六 21时01分28秒 4  5 #include<vector> 6 #include<list> 7 #include<map> 8 #include<set> 9 #include<deque>10 #include<stack>11 #include<bitset>12 #include<algorithm>13 #include<functional>14 #include<numeric>15 #include<utility>16 #include<sstream>17 #include<iostream>18 #include<iomanip>19 #include<cstdio>20 #include<cmath>21 #include<cstdlib>22 #include<cstring>23 #include<ctime>24 #define LL long long25 26 using namespace std;27 int a[10005];28 int main(){29   int  n, m ; 30   scanf("%d %d",&n,&m);31   int maxn = 0; 32   int ans = 0 ;33   for(int i=1 ;i <= n;i ++)34   {35       int temp ; 36       scanf("%d",&temp);37      // printf("%d %d\n",(temp-1)/m,maxn);38       if((temp-1)/ m >=  maxn)39       {40         ans = i ; 41         maxn = (temp-1)/m;42       }43   }44   printf("%d\n",ans);45 return 0;46 }
View Code

B:

循环节

 1 // File Name: b.cpp 2 // Author: darkdream 3 // Created Time: 2014年07月19日 星期六 21时31分19秒 4  5 #include<vector> 6 #include<list> 7 #include<map> 8 #include<set> 9 #include<deque>10 #include<stack>11 #include<bitset>12 #include<algorithm>13 #include<functional>14 #include<numeric>15 #include<utility>16 #include<sstream>17 #include<iostream>18 #include<iomanip>19 #include<cstdio>20 #include<cmath>21 #include<cstdlib>22 #include<cstring>23 #include<ctime>24 #define LL long long25 #define M  100000000726 using namespace std;27 28 int main(){29   int a[5]; 30   scanf("%d %d",&a[1],&a[2]);31   a[1] = (a[1]+M)%M;32   a[2] = (a[2]+M)%M;33   a[3] = a[2] - a[1];34   int n; 35   scanf("%d",&n);36   int t; 37   if((n-1)/3 %2 ==  1)38   {39     t = -a[n%3 == 0?3:n%3];40   41   }else42   {43      t = a[n%3 == 0?3:n%3];44   }45   printf("%d\n",(t+M)%M);46   return 0;47 }
View Code

C:

这场C题我觉得标准的算法应该是CLJ的logn的算法,枚举所有的情况,然后对一每一种情况贪心求得上限减小时间复杂度。

附上他的代码:WJMZBMR

 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstring> 5 #include <string> 6 using namespace std; 7  8 typedef long long int64; 9 10 #define checkMax(a,b) a=max(a,b)11 12 #include <iostream>13 #include <cstdio>14 #include <algorithm>15 #include <cstring>16 #include <string>17 using namespace std;18 19 typedef long long int64;20 21 int main() {22     int n, m, k;23     cin >> n >> m >> k;24     if (n - 1 + m - 1 < k) {25         puts("-1");26         return 0;27     }28     int64 ans = 0;29 //    int cnt = 0;30     for (int64 i = 1; i <= n; i++) {31 //        ++cnt;32         int64 r = n / (n / i);33         i = r;34         if (k - (r - 1) > m - 1)35             continue;36         int64 o = max(k - (r - 1) + 1, 1LL);37         checkMax(ans, 1LL * (n / r) * (m / o));38         //cout << " " << z << " " << t << " " << tt << endl;39     }40 //    cout << cnt << endl;41     cout << ans << endl;42     return 0;43 }
View Code