摘要: 题目:http://codeforces.com/contest/260/problem/A思路:a%b==0 => a*10^n%b==0这题一开始忽略了一句话If there are multiple possible answers, print any of them.想了半天觉得答案不只一种啊然后看到n的范围就知道这题不可能一位位算#include <iostream>#include <cstdlib>using namespace std;int a,b,n;int main(){ cin >> a>>b>>n; 阅读全文
posted @ 2013-01-16 17:05 Daniel Qiu 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 题目:http://codeforces.com/contest/257/problem/A给出接线板 用电器 原有插座的数量;给出每个接线板的插座个数;求最少需要多少插线板;思路:贪心法#include <iostream>#include <cstdlib>using namespace std;int n,m,k;int arr[55];int cmp(const void *a,const void *b){ return *((int *)b)-*((int *)a);}int main(){ cin >> n >> m >> 阅读全文
posted @ 2013-01-16 16:42 Daniel Qiu 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题目:http://codeforces.com/contest/262/problem/A#include <iostream>#include <stdio.h>#include <string.h>using namespace std;int main(){ int n,k; cin >> n >> k; int num; int ans=0; char digit[10]; for(int i=0;i<n;i++) { int counter=0; cin >> num; int flag=1; ... 阅读全文
posted @ 2013-01-16 15:15 Daniel Qiu 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=3030思路:模拟题#include <iostream>using namespace std;int main(){ int n; cin >> n; int r,e,c; for(int i=0;i<n;i++) { cin >> r >> e >> c; if(r<e-c) cout << "advertise" <<endl; else if(r==e-c) cout << "does no 阅读全文
posted @ 2013-01-16 14:18 Daniel Qiu 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1843这题我做了有五个小时...就是没读懂题目中 "从每一个数字开始数一次" 是什么意思...思路:既然是循环我就构建了个循环链表,然后从M往上一个个枚举。#include <iostream>#include <cmath>#include <stdio.h>using namespace std;int digit[10];int num;struct nodes{ int n; nodes *next;}node[10];void create 阅读全文
posted @ 2013-01-16 00:03 Daniel Qiu 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1838输入一个自然数N 请写一个程序来增序输出分母小于等于N的既约真分数思路:将分子分母和值存入结构体 根据值对结构体排序#include <iostream>#include <cstdlib>#include <cmath>using namespace std;struct fraction{ int numerator; int denominator; float value;}f[10000];int cmp(const void *a,const void 阅读全文
posted @ 2013-01-15 17:48 Daniel Qiu 阅读(316) 评论(0) 推荐(0) 编辑
摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1833思路:动态规划f[i-1][j]=max(f[i-1][j]+f[i][j],f[i-1][j]+f[i][j+1])#include <stdio.h>int arr[1000][1000];int max(int a,int b){ if(a>=b) return a; else return b;}int main(){ int n; scanf("%d",&n); for(int i=0;i<n;i++) { for(int j=0;j&l 阅读全文
posted @ 2012-12-30 18:37 Daniel Qiu 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1834求既是回文数又是质数的数思路:先求出100000以内的所有质数,然后判断回文数再判断质数#include<stdio.h>int p[100000]={2};int num;int reverse(int n){ int t=0; if(n>=10) { while(n>0) { t=t*10+n%10; n/=10; }return t; } else return n;}int prime(){ int count... 阅读全文
posted @ 2012-12-29 19:46 Daniel Qiu 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1828 * * * x * * ------- * * * * * * ------- * * * *用给定的数字来取代*,求式子成立的个数思路:枚举法,我的做法是将111*11到999*99全部枚举,也可将输入的数字排列枚举。#include <stdio.h>#include <stdlib.h>int arr[10];int ans=0;int n;int inarr(int x){ int num; if(x/100==0) num=2... 阅读全文
posted @ 2012-12-25 15:39 Daniel Qiu 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 题目:http://hustoj.sinaapp.com/problem.php?id=1826用个数固定总长最小的几块木板 覆盖不连续的区间 求木板总长思路:快排 贪心法#include <stdio.h>#include <stdlib.h>int arr[210];int gap[210];int cmp(const void *a,const void *b){ return *(int*)a-*(int *)b;}int main(){ int ans=0; int m,s,c; scanf("%d%d%d",&m,&s,& 阅读全文
posted @ 2012-12-25 00:19 Daniel Qiu 阅读(237) 评论(0) 推荐(0) 编辑