上一页 1 ··· 161 162 163 164 165 166 167 168 169 ··· 182 下一页
摘要: 把各个位上的大于4的数都减一, 例如:15变成14,67变成56.然后把这个数字当成是9进制,用java转为10进制输出。View Code import java.util.*;import java.io.*;import java.math.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); while (cin.hasNext()) { String st = cin.nextLine() 阅读全文
posted @ 2011-03-22 09:44 undefined2024 阅读(278) 评论(0) 推荐(0)
摘要: 用两个数组来存最大值和最小值,每次用冒泡的方式维护。View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 20int n1, n2, n;int f1[maxn], f2[maxn];void up1(int f[], int x){ for (int i = x - 1; i >= 0; i--) { if (f[i] < f[i + 1]) swap(f[i 阅读全文
posted @ 2011-03-20 16:13 undefined2024 阅读(277) 评论(0) 推荐(0)
摘要: 题意:人们一个一个的来排队并插队,按人到来的顺序给出每个人插队的位置(插在第几个人后面),并告知每个人的id号,输出最终队伍的情况。分析:可以用线段树,从最后来的一个人开始向来得更早的人遍历,这样pos(插在第几个人后面)的意义就变成了,前面有多少个空位。线段树上每个节点中存储的是当前时刻,该区间有多少空位。View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>usingnamespace std;#define maxn 200005s 阅读全文
posted @ 2011-03-20 15:52 undefined2024 阅读(2386) 评论(2) 推荐(0)
摘要: 题意:给定一个数列,从左至右输出每个长度为m的数列段内的最小数和最大数。分析:在这里我们以求最大值为例,最小值同理。用单调双向队列来做,动态规划。从左到右把窗户推一便,每推一格,就把新来的元素入队,入队过程中先把队尾小于它的元素全去掉(因为这些值不可能成为窗子区间内的最大值了),再把它加到队尾。这样就保证了队列中元素是单调递减的。还要注意及时把不在窗户区间内的队首元素弹出。每次要取窗子区间内的最大值,只需看队首元素即可。View Code #include #include #include #include usingnamespace std;#define maxn 1000005str 阅读全文
posted @ 2011-03-20 14:40 undefined2024 阅读(238) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;int main(){ //freopen("D:\\t.txt", "r", stdin); int t; scanf("%d", &t); long long n,m; for (int i = 0; i < t; i++) { scanf("%I64d 阅读全文
posted @ 2011-03-19 18:39 undefined2024 阅读(229) 评论(0) 推荐(0)
上一页 1 ··· 161 162 163 164 165 166 167 168 169 ··· 182 下一页