2014年2月20日
摘要: 原题链接复杂度O(logn);#include #define mod 10003int f(int a, int n){ if(n == 0) return 1 % mod; if(n == 1) return a % mod; int t = f(a, n / 2); t = t * t % mod; if(n & 1) return t * a % mod; return t;}int main(){ int t, a, n, s, i; scanf("%d", &t); while(t-- && scanf("%d%d&qu 阅读全文
posted @ 2014-02-20 22:58 长木Qiu 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 原题链接string.find(); 和 string.replace();的用法。#include #include using namespace std;int main(){ string str; int p; while(getline(cin, str)){ p = str.find("you"); while(p != string::npos){ str.replace(p, 3, "we"); p = str.find("you", p + 1); } cout << str << endl 阅读全文
posted @ 2014-02-20 10:02 长木Qiu 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 原题链接strtok + sort就搞定了。#include #include #include using namespace std;#define MAX 1000 + 2char str[MAX];int a[MAX];int main(){ int count; char *p; while(scanf("%s", str) == 1){ count = 0; p = strtok(str, "5"); while(p != NULL){ sscanf(p, "%d", &a[count++]); p = strto 阅读全文
posted @ 2014-02-20 09:27 长木Qiu 阅读(138) 评论(0) 推荐(0) 编辑