POJ 3673 Cow Multiplication (水题)
题意:给你两个数,求所有的数位的积的和。
析:太水了,没的说,可以先输入边算,也可以最后再算,一样。。
代码如下:
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
using namespace std ; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1000 + 5;
const int dr[] = {0, 0, -1, 1};
const int dc[] = {-1, 1, 0, 0};
int m, n;
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
while(scanf("%d %d", &n, &m) == 2){
int a[15], b[15];
int cnt1 = 0, cnt2 = 0;
while(n){
a[cnt1++] = n % 10;
n /= 10;
}
while(m){
b[cnt2++] = m % 10;
m /= 10;
}
int ans = 0;
for(int i = 0; i < cnt1; ++i)
for(int j = 0; j < cnt2; ++j)
ans += a[i] * b[j];
printf("%d\n", ans);
}
return 0;
}
POJ 3673 Cow Multiplication (水题)的更多相关文章
- POJ 3673 Cow Multiplication
Cow Multiplication Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13312 Accepted: 93 ...
- POJ 1488 Tex Quotes --- 水题
POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...
- POJ 3641 Oulipo KMP 水题
http://poj.org/problem?id=3461 直接KMP就好.水题 #include<cstdio> #include<cstring> const int M ...
- poj 1006:Biorhythms(水题,经典题,中国剩余定理)
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 110991 Accepted: 34541 Des ...
- poj 1002:487-3279(水题,提高题 / hash)
487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 236746 Accepted: 41288 Descr ...
- poj 1003:Hangover(水题,数学模拟)
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 99450 Accepted: 48213 Descri ...
- poj 2105 IP Address(水题)
一.Description Suppose you are reading byte streams from any device, representing IP addresses. Your ...
- poj 2000 Gold Coins(水题)
一.Description The king pays his loyal knight in gold coins. On the first day of his service, the kni ...
- poj 1035 Spell checker(水题)
题目:http://poj.org/problem?id=1035 还是暴搜 #include <iostream> #include<cstdio> #include< ...
随机推荐
- JasperReports+iReport打印为excel表头重复问题解决
iReport版本:3.7.4 解决方法很简单,无奈我就是纠结了一个多小时... 首先,点击文件根目录 移到 属性 框里面,找到Ignore pagination项,勾上,忽略分页,一切就OK了.
- CocoaPods requires your terminal to be using UTF-8 encoding
WARNING: CocoaPods requires your terminal to be using UTF-8 encoding. See https://github.com/CocoaPo ...
- JdbcTemplate查询数据 三种callback之间的区别
JdbcTemplate针对数据查询提供了多个重载的模板方法,你可以根据需要选用不同的模板方法. 如果你的查询很简单,仅仅是传入相应SQL或者相关参数,然后取得一个单一的结果,那么你可以选择如下一组便 ...
- powerScript脚本
一.powerScript的语法 1.0变量的命名及使用 powerscript的标识符(变量名称)必须以字母或下划线开头,其它的字符可以是下划线(_).短横线(-).美元符号($).号码符号(#) ...
- android通过httpClient请求获取JSON数据并且解析
使用.net创建一个ashx文件,并response.write json格式 public void ProcessRequest(HttpContext context) { context.R ...
- 推荐 15 个 Angular.js 应用扩展指令(参考应用)
几天前我们看到Angular 1.4.0发布了-一个以社团为驱动的发布版本涵盖了400多个GitHub的提交,增加了对特性的提升,比如动画,以及可用性. 官方新闻发布稿 覆盖了绝大部分,这同样值得放于 ...
- 解决WCF大数据量传输 ,System.Net.Sockets.SocketException: 远程主机强迫关闭了一个现有的连接
开发中所用的数据需要通过WCF进行数据传输,结果就遇到了WCF大量传输问题 也就是提示System.Net.Sockets.SocketException: 远程主机强迫关闭了一个现有的连接 网上解决 ...
- Js原型模式
function Person(){ } Person.prototype.name = "xd"; Person.prototype.age = 26; Person.proto ...
- HDU 5874 Friends and Enemies
Friends and Enemies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- Cyborg Genes
题意: 给两个字符串,求最短的以两字符串为子序列的字符串和个数 分析: 最长公共子序列的变形,num[i][j]表示个数 #include <map> #include <set&g ...