惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
博客园_首页
N
News | PayPal Newsroom
有赞技术团队
有赞技术团队
The Hacker News
The Hacker News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
S
SegmentFault 最新的问题
Jina AI
Jina AI
人人都是产品经理
人人都是产品经理
P
Privacy & Cybersecurity Law Blog
AI
AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Schneier on Security
Schneier on Security
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
量子位
Forbes - Security
Forbes - Security
爱范儿
爱范儿
云风的 BLOG
云风的 BLOG
SecWiki News
SecWiki News
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tor Project blog
Recorded Future
Recorded Future
A
About on SuperTechFans
J
Java Code Geeks
The Register - Security
The Register - Security
PCI Perspectives
PCI Perspectives
H
Hacker News: Front Page
V2EX - 技术
V2EX - 技术
S
Secure Thoughts
V
Vulnerabilities – Threatpost
Hacker News: Ask HN
Hacker News: Ask HN
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Scott Helme
Scott Helme
T
The Exploit Database - CXSecurity.com
Y
Y Combinator Blog
AWS News Blog
AWS News Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
IT之家
IT之家
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
C
CERT Recently Published Vulnerability Notes
L
LangChain Blog
F
Full Disclosure
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The GitHub Blog
The GitHub Blog

博客园 - saintqdd

hdu 1102 pku 2421 解题报告 pku 2777 Count Color 解体报告 石子合并问题 nkoj1139和乘积最大那题一样. A Tour in Loquat Orchard (FZU 2007 ICPC Qualification Round I tzw) 最大黑区域 滑雪 一道经典题,humble number 今天碰到了一个很诡异的题,Alphacode (zoj 2202) 这两天经常碰到dp题,就写了一个0-1背包 实训以来,到这里的次数少了! 郁闷,乘积最大那题WA原来只是因为我用了pow函数引起的! Smith Number POJ强烈推荐50题 JOJ 2391 words 三十分钟掌握STL STL学习小记 POJ1006,中国剩余定理 POJ1003,简单题
POJ 1014
saintqdd · 2007-08-05 · via 博客园 - saintqdd

这道题可以归为dp典型问题,但是在数据处理上还是要注意一下,不然很容易超时。

#include<iostream>
int ok;
int arr[7];
void find(int now,int x){
    if(x==0)
        return;
    int i,s,t;
    s=now/x;
    t=s>arr[x]?arr[x]:s;
    if((now-x*t)!=0){
        for(i=t;i>=0;i--){
            find(now-x*i,x-1);
            if(ok)
                return;
        }
    }
    else{
        ok=1;
        return;
    }
}
int main(){
    int sum,p=1;
    while(scanf("%d%d%d%d%d%d",&arr[1],&arr[2],&arr[3],&arr[4],&arr[5],&arr[6])&&!(arr[1]==0&&arr[2]==0&&arr[3]==0&&arr[4]==0&&arr[5]==0&&arr[6]==0)){
        arr[1]%=24;arr[2]%=24;arr[3]%=24;arr[4]%=24;arr[5]%=24;arr[6]%=24;
       //这里尤其要注意,不取摸是会超时的。取摸的方法是对6的倍数取摸如(12,18,24,30,。。。)
        sum=1*arr[1]+2*arr[2]+3*arr[3]+4*arr[4]+5*arr[5]+6*arr[6];
        ok=0;
        if(sum%2){
            printf("Collection #%d:\n",p++);
            printf("Can't be divided.\n");
        }
        else{
            find(sum/2,6);
            if(ok){
                printf("Collection #%d:\n",p++);
                printf("Can be divided.\n");
            }
            else{
                printf("Collection #%d:\n",p++);
                printf("Can't be divided.\n");
            }
        }
        if(p!=1)
            printf("\n");
    }
}