BestCoder Round 70

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BestCoder Round 70相关的知识,希望对你有一定的参考价值。

惨败,不能再嘲笑别人了,否则自己也会像别人那样倒霉

1001:http://acm.hdu.edu.cn/showproblem.php?pid=5615

求ax^2+bx+c能否拆成(px+k)(qx+m)的形式

不错的方法,原来的被hack了

技术分享
 1 #include <cstdio>
 2 #include <iostream>
 3 #include <cmath>
 4 #include <cstring>
 5 #include <queue>
 6 #include <vector>
 7 #include <algorithm>
 8 
 9 #define rep(i,a,n) for(int i = a;i < n;i++)
10 #define per(i,n,a) for(int i = n-1;i >=a;i--)
11 #define pb push_back
12 #define VI vector<int>
13 #define QI queue<int>
14 #define log2(N) log10(N)/log10(2)
15 #define eps 1e-8
16 
17 typedef long long ll;
18 
19 using namespace std;
20 
21 
22 int main(){
23     int T;
24     scanf("%d",&T);
25     while(T--){
26         ll a,b,c,d;
27         scanf("%I64d%I64d%I64d",&a,&b,&c);
28         d = b*b - 4*a*c;
29         if(d == (ll)sqrt(d)*(ll)sqrt(d)){
30             puts("YES");
31         }
32         else{
33             puts("NO");
34         }
35     }    
36     return 0;
37 }
View Code

1002:http://acm.hdu.edu.cn/showproblem.php?pid=5616

01背包,记得要来回两次

另外为了简便用到了操作符或 0|0 = 0, 0|1 = 1, 1|1 = 1

技术分享
 1 #include <cstdio>
 2 #include <iostream>
 3 #include <cmath>
 4 #include <cstring>
 5 #include <queue>
 6 #include <vector>
 7 #include <algorithm>
 8 
 9 #define rep(i,a,n) for(int i = a;i < n;i++)
10 #define per(i,n,a) for(int i = n-1;i >=a;i--)
11 #define pb push_back
12 #define VI vector<int>
13 #define QI queue<int>
14 #define log2(N) log10(N)/log10(2)
15 #define eps 1e-8
16 
17 typedef long long ll;
18 
19 using namespace std;
20 
21 const int N = 20 + 5;
22 const int MAXN = 2000 + 5;
23 int n,sum;
24 int a[N] = {};
25 int dp[MAXN] = {};
26 
27 int main(){
28     int T;
29     scanf("%d",&T);
30     while(T--){
31         sum = 0;
32         scanf("%d",&n);
33         rep(i,0,n){
34             scanf("%d",&a[i]);
35             sum += a[i];
36         }  
37         memset(dp,0,sizeof(dp));
38         dp[0] = 1;
39         rep(i,0,n){
40             per(j,sum+1,a[i]){
41                 dp[j] |= dp[j-a[i]];
42             }
43         }
44         rep(i,0,n){
45             rep(j,0,sum-a[i]+1){
46                 dp[j] |= dp[j+a[i]];
47             }
48         }
49         int z;
50         scanf("%d",&z);
51         while(z--){
52             int s;
53             scanf("%d",&s);
54             if(dp[s]){
55                 printf("YES\n");
56             }
57             else{
58                 printf("NO\n");
59             }
60         }
61     }    
62     return 0;
63 }
View Code

立个FLAG,我要再做出1003

以上是关于BestCoder Round 70的主要内容,如果未能解决你的问题,请参考以下文章

BestCoder Round #70 Jam's math problem(hdu 5615)

BestCoder Round #75

BestCoder Round #92

ACM学习历程—BestCoder Round #75

BestCoder Round #88

BestCoder Round #90