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

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - 张瓅

puppy-language ConsolePlayer 仙剑奇侠传4主题曲 QBASIC代码 HTML5 模版调用析构函数的一个发现 编译期运算 如何测量代码执行时间 【转】老外眼中的武侠小说 1850年的宁波 关于安装 DirectX SDk Dec 2005 后无法编译DirectShow应用程序的问题 [转]VB中嵌入汇编与真正的DLL 新的连连看网络版 各种连接字符串 关于CSS属性display:none和visible:hidden的区别 Fire Net 尝试了一下Flex VFP中如何调用API函数 DES加密算法的实现 软件项目经理必备素质(转)
我用超白痴的方法解出了这道题,大家有没有更好的方法
张瓅 · 2005-11-11 · via 博客园 - 张瓅
Dick and Jane
Time limit: 1 Seconds   Memory limit: 32768K  
Total Submit: 208   Accepted Submit: 92  

Dick is 12 years old. When we say this, we mean that it is at least twelve and not yet thirteen years since Dick was born.

Dick and Jane have three pets: Spot the dog, Puff the Cat, and Yertle the Turtle. Spot was s years old when Puff was born; Puff was p years old when Yertle was born; Spot was y years old when Yertle was born. The sum of Spot's age, Puff's age, and Yertle's age equals the sum of Dick's age (d) and Jane's age (j). How old are Spot, Puff, and Yertle?

Each input line contains four non-negative integers: s, p, y, j. For each input line, print a line containing three integers: Spot's age, Puff's age, and Yertle's age. Ages are given in years, as described in the first paragraph.

Sample Input

5 5 10 9
5 5 10 10
5 5 11 10

Output for Sample Input

12 7 2
13 7 2
13 7 2

Problem Source: University of Waterloo Local Contest 1998.06.06

我用的是傻得无以复加的方法,而且差0.02s就超时了,好险!

//http://acm.zju.edu.cn/show_problem.php?pid=1110

#include
<iostream>
using namespace std;
main()
{
    
const int d=12;
    
int s,p,y,j;
    
float sa,pa,ya;

    
while(  scanf("%d%d%d%d",&s,&p,&y,&j)!=EOF)
    
{
       
for(ya=0.0;ya<=50;ya+=0.1)
        
{
            
for(pa=ya;pa<=ya+p+3;pa+=0.1)
            
{
                
for(sa=pa;sa<=ya+y+3;sa+=0.1)
                
{
                    
if ( (int(sa-pa)==s) && (int(sa-ya)==y) && (int(pa-ya)==p) && (int(sa)+int(pa)+int(ya)==d+j) )
                        
goto finish;
                }

            }

        }

finish:  
        printf(
"%.0f %.0f %.0f\n",sa,pa,ya);

    }

}


大家有更好的算法吗?