zoukankan      html  css  js  c++  java
  • hoj 13926 Floppy Music

    //手动memset就wa了
    #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; typedef long long LL; const int maxn=(int)1e4 +10; int a[105][maxn]; int main() { #ifdef shuaishuai freopen("C:\Users\hasee\Desktop\a.txt","r",stdin); //freopen("C:\Users\hasee\Desktop\b.txt","w",stdout); #endif int T; int t,n; scanf("%d",&T); while(T--) { scanf("%d%d",&t,&n); memset(a,0,sizeof a); for(int i=0; i<=t; i++) a[0][i]=1; int x,y; for(int i=1; i<=n; i++) { scanf("%d%d",&x,&y); int len=y-x; for(int j=0; j<=t; j++) { if(j-len>=0) a[i][j]|=a[i-1][j-len]; if(j+len<=t) a[i][j]|=a[i-1][j+len]; } } // for(int i=0;i<=n;i++){ // for(int j=0;j<=t;j++)printf("%d ",a[i][j]);printf(" "); // } int flag=0; for(int i=0; i<=t; i++) { flag|=a[n][i]; } if(!flag) { printf("impossible "); return 0; } } printf("possible "); return 0; }
  • 相关阅读:
    C++ 的查漏补缺
    Model元数据解析
    Controller
    路由
    win8系统 Reflect 破解
    MVC运行原理
    源代码Log
    linq 分类
    EF 实体关系
    第二十六章 计算限制的异步操作
  • 原文地址:https://www.cnblogs.com/MeowMeowMeow/p/7445960.html
Copyright © 2011-2022 走看看