1000: A+B Problem(NetWork Flow)
1000: A+B Problem
Time Limit: 1 Sec Memory Limit: 5 MB
Submit: 11814 Solved: 7318
[Submit][Status][Discuss]
Description
Calculate a+b
Input
Two integer a,b (0<=a,b<=10)
Output
Output a+b
Sample Input
Sample Output
HINT
Q: Where are the input and the output? A: Your program shall always read input from stdin (Standard Input) and write output to stdout (Standard Output). For example, you can use 'scanf' in C or 'cin' in C++ to read from stdin, and use 'printf' in C or 'cout' in C++ to write to stdout. You shall not output any extra data to standard output other than that required by the problem, otherwise you will get a "Wrong Answer". User programs are not allowed to open and read from/write to files. You will get a "Runtime Error" or a "Wrong Answer" if you try to do so. Here is a sample solution for problem 1000 using C++/G++:
#include
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << a+b << endl;
return 0;
}
It's important that the return type of main() must be int when you use G++/GCC,or you may get compile error. Here is a sample solution for problem 1000 using C/GCC:
#include int main()
{
int a,b;
scanf("%d %d",&a, &b);
printf("%d\n",a+b);
return 0;
}
Here is a sample solution for problem 1000 using PASCAL:
program p1000(Input,Output);
var
a,b:Integer;
begin
Readln(a,b);
Writeln(a+b);
end.
Here is a sample solution for problem 1000 using JAVA: Now java compiler is jdk 1.5, next is program for 1000
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String args[]) throws Exception
{
Scanner cin=new Scanner(System.in);
int a=cin.nextInt(),b=cin.nextInt();
System.out.println(a+b);
}
}
Old program for jdk 1.4
import java.io.*;
import java.util.*; public class Main
{
public static void main (String args[]) throws Exception
{
BufferedReader stdin =
new BufferedReader(
new InputStreamReader(System.in)); String line = stdin.readLine();
StringTokenizer st = new StringTokenizer(line);
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
System.out.println(a+b);
}
}
Source
/**************************************************************
Problem:
User: HansBug
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/ type
point=^node;
node=record
g,w:longint;
next,anti:point;
end;
var
i,j,k,l,m,n,ans,s,t,x,y:longint;
a:array[..] of point;
d,dv:array[..] of longint;
function min(x,y:longint):longint;
begin
if x<y then min:=x else min:=y;
end;
procedure add(x,y,z:longint);
var p:point;
begin
new(p);p^.g:=y;p^.w:=z;p^.next:=a[x];a[x]:=p;
new(p);p^.g:=x;p^.w:=;p^.next:=a[y];a[y]:=p;
a[x]^.anti:=a[y];a[y]^.anti:=a[x];
end;
function dfs(x,flow:longint):longint;
var p:point;k:longint;
begin
if x=t then exit(flow);
dfs:=;p:=a[x];
while p<>nil do
begin
if (p^.w<>) and (d[x]=(d[p^.g]+)) then
begin
k:=dfs(p^.g,min(flow-dfs,p^.w));
if p^.w<>maxlongint then dec(p^.w,k);
if p^.anti^.w<>maxlongint then inc(p^.anti^.w,k);
inc(dfs,k);if dfs=flow then exit;
end;
p:=p^.next;
end;
if d[s]=n then exit;
dec(dv[d[x]]);
if dv[d[x]]= then d[s]:=n;
inc(d[x]);inc(dv[d[x]]);
end;
begin
readln(x,y);n:=;s:=;t:=;
for i:= to n do a[i]:=nil;
add(s,t,x);add(s,t,y);
fillchar(d,sizeof(d),);
fillchar(dv,sizeof(dv),);
dv[]:=n;ans:=;
while d[s]<n do inc(ans,dfs(s,maxlongint));
writeln(ans);
readln;
end.
1000: A+B Problem(NetWork Flow)的更多相关文章
- 数据结构与算法分析 - 网络流入门(Network Flow)
转载:网络流基础篇--Edmond-Karp算法 BY纳米黑客 网络流的相关定义: 源点:有n个点,有m条有向边,有一个点很特殊,只出不进,叫做源点. 汇点:另一个点也很特殊, ...
- HDU 3549 Flow Problem(最大流)
HDU 3549 Flow Problem(最大流) Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...
- Flow Problem(最大流)
Flow Problem Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Tot ...
- hdoj--3549--Flow Problem(最大流)
Flow Problem Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Tot ...
- P1832 A+B Problem(再升级)
P1832 A+B Problem(再升级) 题目提供者 usqwedf 传送门 标签 动态规划 数论(数学相关) 洛谷原创 难度 普及/提高- 通过/提交 107/202 题目背景 ·题目名称是吸引 ...
- css布局详解(二)——标准流布局(Nomal flow)
css标准流布局(Nomal flow) 一.正常流 这是指西方语言中文本从左向右,从上向下显示,这也是我们熟悉的传统的HTML文档中的文本布局.注意,在非西方的语言中,流方向可能不同.大多数元素都在 ...
- VMware虚拟机上网络连接(network type)的三种模式--bridged、host-only、NAT
VMware虚拟机上网络连接(network type)的三种模式--bridged.host-only.NAT VMWare提供了三种工作模式,它们是bridged(桥接模式).NAT(网络地址转换 ...
- 题解 P1601 【A+B Problem(高精)】
P1601 A+B Problem(高精) 题目描述 高精度加法,x相当于a+b problem,b不用考虑负数. 输入输出格式 输入格式: 分两行输入a,b<=10^500 输出格式: 输出只 ...
- A+B Problem(再升级)
洛谷P1832 A+B Problem(再升级) ·给定一个正整数n,求将其分解成若干个素数之和的方案总数. 先说我的垃圾思路,根本没有验证它的正确性就xjb写的,过了垃圾样例,还水了20分,笑哭.. ...
随机推荐
- V8引擎嵌入指南
如果已读过V8编程入门那你已经熟悉了如句柄(handle).作用域(scope)和上下文(context)之类的关键概念,以及如何将V8引擎作为一个独立的虚拟机来使用.本文将进一步讨论这些概念,并介绍 ...
- loadrunner controller:实时查看VUser的运行情况
1) 如下图,在Run标签页,点击"Vusers..."打开Vuser窗口: 2) 如下图选中一个Vuser点击按钮可以打开Run-Time Vie ...
- We Chall-Training: ASCII—Writeup
MarkdownPad Document html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,ab ...
- 龙珠超的新OP【限界突破×サバイバー】
这首歌真的很燃 下载>> 限界突破×サバイバー 中文歌词 演唱:冰川清志 兴奋了!就去宇宙吧 最先端的“着迷”怎么样! 握在手中 突然想要大笑 糊里糊涂也习惯了吗! I can't g ...
- Windows下MySQL多实例安装/主从复制/重置密码
Windows创建MySQL多实例 安装MYSQL和实例1 运行mysql-installer-community-5.7.16.0.msi 选择组件 MySQL Server 5.7.16 – X6 ...
- 很傻很二很简单的一个问题,json键值为变量如何取值
js里的json的键值是变量的话,那么传统的做法似乎不管用了. 例如: var json={'a':'123','b':'999'} json.a得到123,如果a用变量表示呢,有笨法for循环 ...
- MVC View显示详解(RenderBody,RenderPage,RenderSection,Partial)
一.Views文件夹 -> Shared文件夹下的 _Layout.cshtml 母版页 @RenderBody 当创建基于_Layout.cshtml布局页面的视图时,视图的内容会和布局页面合 ...
- tableView的总结
// // ViewController.m // TableViewController // // Created by 王妍 on 16/3/23. // Copyright © 2016年 c ...
- Vue2.0源码阅读笔记--生命周期
一.Vue2.0的生命周期 Vue2.0的整个生命周期有八个:分别是 1.beforeCreate,2.created,3.beforeMount,4.mounted,5.beforeUpdate,6 ...
- 【转载】简析TCP的三次握手与四次分手
最近在补习HTTP协议相关知识点,看到这篇讲得不错,所以转载收藏一下,同时也分享给大家.原文地址:http://www.jellythink.com/archives/705,版权归原作者所有. TC ...