swjtuoj 2383 Music Problem
来源:互联网 发布:苹果蜂窝移动网络位置 编辑:程序博客网 时间:2024/06/06 01:56
题目链接:Music Problem
题目大意:给你一堆正整数,问能不能从中间找出来一些数他们的和对3600求余为零
题目思路:模拟01背包,暴力写一下就好
#include <bits/stdc++.h>using namespace std;int t,n,a[100005];void solve(){ scanf("%d",&n); for(int i = 1; i <= n; i++) scanf("%d",&a[i]); a[1] %= 3600; int dp[4005] = {0}; vector<int>v; dp[a[1]] = 1; if(dp[0]){ cout<<"YES"<<endl; return ; } v.push_back(a[1]); for(int i = 2; i <= n; i++){ int xx = a[i]%3600; int si = v.size(); if(dp[xx] == 0){ dp[xx] = 1; v.push_back(xx); } if(!xx){ cout<<"YES"<<endl; return ; } for(int j = 0;j < si;j++){ int tmp = (v[j]+a[i])%3600; if(dp[tmp]) continue; dp[tmp] = 1; v.push_back(tmp); } if(dp[0]){ cout<<"YES"<<endl; return ; } } cout<<"NO"<<endl;}int main(){ ios::sync_with_stdio(false); scanf("%d",&t); while(t--){ solve(); } return 0;}
阅读全文
0 0
- swjtuoj 2383 Music Problem
- swjtuoj 2380 Knapsack Problem
- SWJTUOJ-2366 A chess Problem (easy)
- SWJTUOJ-2364 A room Problem(easy)
- SWJTUOJ-2397 A Easy Counting Problem
- swjtu2383(Music Problem)
- Music
- music
- music
- music~~
- Music
- music
- music
- Music
- music
- Music
- Music
- @@music@@
- php 操作mongodb
- 各种流量采集方式的性能对比测试结果
- 漫谈重构
- 此博客已整体转至yayar.top
- 加密算法分类
- swjtuoj 2383 Music Problem
- ssm:全局异常处理器
- 51nod 1625 夹克爷发红包
- 第一天Socket编程
- app:processDebugManifest'. > Manifest merger failed with multiple errors, see logs
- 如何完全卸载Oracle 11g
- ListView中item点事件和item中的控件点击事件冲突的简易解决方法
- [unity3D基础篇04]性能优化基础1
- mac版MySQL初始密码设置