优先队列,真是水的不行~
保持队列里只有K个元素即可
#include
#include
using namespace std;
priority_queue, greater >mapp;
int n,k;
string cmd;
int main()
{
while(cin>>n>>k)
{
while(mapp.size()) mapp.pop();
while(n--)
...
分类:
其他好文 时间:
2015-04-22 22:21:58
阅读次数:
105
考察优先队列,不过要注意优先队列的优先排序是不稳定排序,解决方法和自定义排序一样,再添加一个参数即可
#include
#include
using namespace std;
string cmd;
struct stu
{
string name;
int p,lv,num;
friend bool operator<(stu x,stu y)
{
if(x.lv==y.lv)...
优先队列,注意队列开始时就只有一个数的特殊情况
#include
#include
using namespace std;
int m;
int rem[26];
priority_queue,greater >mapp;
int main()
{
int t;
cin>>t;
while(t--)
{
int m;
string ans;
cin>>m>>ans;
f...
分类:
其他好文 时间:
2015-04-22 22:19:39
阅读次数:
188
public class SendEmail {
private static final String TAG = "SendEmail";
//要发送Email地址
private String mailTo = null;
//邮件发送来源地址
private String mailFrom = null;
//SMTP主机...
分类:
移动开发 时间:
2015-04-22 22:19:29
阅读次数:
308
应用程序递归太深而发生堆栈溢出
package com.basic.extend;
public class MainDemo {
public static void main(String[] args) {
MainDemo mainDemo = new MainDemo();
mainDemo.count(1, 1);
}
public void coun...
分类:
其他好文 时间:
2015-04-22 22:13:53
阅读次数:
122
1. 找出下列代码的错误void test(){ char string[10]; char *str="0123456789"; strcpy(string,str);}字符串str需要11个字节才能存放下(包括末尾的'\0'),而string只有10个字节的空间;strcpy会导致数组越界...
分类:
编程语言 时间:
2015-04-22 22:07:37
阅读次数:
133
简单的模拟题,类似于高精度加法运算。理解题意即可。#include#include#include#includeusing namespace std;const int maxn = 111;char s[maxn];char ji[maxn];int gg[maxn];void RevStr(...
分类:
其他好文 时间:
2015-04-22 22:01:33
阅读次数:
160
题目给定一个字符串类型(string)表示的小数,打印出它的二进制表示。 如果这个数无法精确地表示为二进制形式,输出”ERROR”。解答整数部分通过不断地对2取余然后除以2来得到其二进制表示, 或是不断地和1按位与然后除以2得到其二进制表示。 小数部分则通过不断地乘以2然后与1比较来得到其二进制表示...
分类:
其他好文 时间:
2015-04-22 21:58:46
阅读次数:
132
int testi=9;string tests=std::to_string(testi);如果不能运行,修改 makefile CXX=g++ -std = c++11
分类:
编程语言 时间:
2015-04-22 20:36:26
阅读次数:
185
'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input string (not partial).The...
分类:
其他好文 时间:
2015-04-22 20:34:04
阅读次数:
122