10970 - Big Chocolate

题意 :已知n*m的巧克力,问需要掰多少次能让巧克力成为最小的一块;

1 #include<iostream>
2 using namespace std;
3 int main()
4 {
5     int n,m;
6     while(cin>>n>>m)
7         cout<<n*m-1<<endl;
8     return 0;
9 }
时间: 2024-11-05 13:34:33

10970 - Big Chocolate的相关文章

UVA 11636 Hello World,LA 3602 DNA Consensus String,UVA 10970 Big Chocolate,UVA 10340 All in All,UVA 11039 Building Designing

课程好紧啊,只能刷点水题了,几乎都是贪心. UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { int n,kas = 0; while(scanf("%d",&n),n>0){ int r = 0; for(n--;n;n>>=1) r++; printf("Case %d: %d\n",++kas,r); }

UVa 10970 Big Chocolate (想一下就AC了)

题意:给你一个m*n的巧克力,让人把它切成1*1的,但是每次只能切一下,问要切多少刀. 析:简单啊,我就不明白了 怎么那么多人TLE了,不会当DP做了吧,其实不用的. 假设有一个1*m的巧克力,很明显知道是切m-1刀,那么再把n把变成1,要n-1刀,加起来就OK. 代码如下: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <vecto

UVA题目分类

题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes

codeforces 598E E. Chocolate Bar(区间dp)

题目链接: E. Chocolate Bar time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you ma

CodeForces Round 279 D Chocolate

Polycarpus likes giving presents to Paraskevi. He has bought two chocolate bars, each of them has the shape of a segmented rectangle. The first bar is a1 × b1 segments large and the second one is a2 × b2 segments large. Polycarpus wants to give Paras

2015: [Usaco2010 Feb]Chocolate Giving

2015: [Usaco2010 Feb]Chocolate Giving Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 269  Solved: 183[Submit][Status] Description Farmer John有B头奶牛(1<=B<=25000),有N(2*B<=N<=50000)个农场,编号1-N,有M(N-1<=M<=100000)条双向边,第i条边连接农场R_i和S_i(1<=R_i&

洛谷—— P2983 [USACO10FEB]购买巧克力Chocolate Buying

https://www.luogu.org/problem/show?pid=2983 题目描述 Bessie and the herd love chocolate so Farmer John is buying them some. The Bovine Chocolate Store features N (1 <= N <= 100,000) kinds of chocolate in essentially unlimited quantities. Each type i of

洛谷 P2984 [USACO10FEB]给巧克力Chocolate Giving

题目描述 Farmer John is distributing chocolates at the barn for Valentine's day, and B (1 <= B <= 25,000) of his bulls have a special cow in mind to receive a chocolate gift. Each of the bulls and cows is grazing alone in one of the farm's N (2*B <=

codeforces 490 D Chocolate

题意:给出a1*b1和a2*b2两块巧克力,每次可以将这四个数中的随意一个数乘以1/2或者2/3,前提是要可以被2或者3整除,要求最小的次数让a1*b1=a2*b2,并求出这四个数最后的大小. 做法:非常显然仅仅跟2跟3有关.所以s1=a1*b1,s2=a2*b2,s1/=gcd(s1,s2),s2/=gcd(s1,s2),然后若s1跟s2的质因子都是2跟3,那么就有解.之后暴力乱搞就好了. #include<map> #include<string> #include<cs