zoukankan      html  css  js  c++  java
  • codeforces 1097B Petr and a Combination Lock

    题目链接:https://vjudge.net/problem/CodeForces-1097B

    对于给出的每一个度数,我们只有两种情况,要么加上它要么减去它,因为题目给出的n最大只有15,所以当然是选择暴☆搜啦。

    #include<set>
    #include<map>
    #include<stack>
    #include<queue>
    #include<cmath>
    #include<cstdio>
    #include<cctype>
    #include<string>
    #include<vector>
    #include<climits>
    #include<cstring>
    #include<cstdlib>
    #include<iostream>
    #include<algorithm>
    #define max(a, b) (a > b ? a : b)
    #define min(a, b) (a < b ? a : b)
    #define mst(a) memset(a, 0, sizeof(a))
    #define _test printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> P;
    const double eps = 1e-7;
    const int INF = 0x3f3f3f3f;
    const ll ll_INF = 233333333333333;
    const int maxn = 4e6 + 10;
    int arr[maxn];
    bool dfs(int i, int n, int sum) {
        if (i == n) 
            return !(sum % 360);
        return dfs(i+1, n, sum + arr[i]) || dfs(i+1, n, sum - arr[i]);
    }
    int main(void) {
        int n;
        cin >> n;
        for (int i = 0; i<n; i++)
            cin >> arr[i];
        printf(dfs(0,n,0) ? "YES\n" : "NO\n");
        return 0;
    }
    
    
  • 相关阅读:
    Mysql常用函数总结(二)
    mysql百万的数据快速创建索引
    php 中的sprintf 坑
    php5.5之后新特性整理
    mysql实践总结
    php下载远程图片到本地
    搜藏一个php文件上传类
    Attribute基本介绍
    Fiddler4抓包工具使用教程一
    HTTP传输数据压缩
  • 原文地址:https://www.cnblogs.com/shuitiangong/p/12266515.html
Copyright © 2011-2022 走看看