Aggressive cows 二分,关键是转化为二分! 1 #include <cstdio> 2 #include <algorithm> 3 const int maxn = 1000000005; 4 const int maxN = 100005; 5 6 int N, C; 7 int a[maxN]; 8 using namespace std; 9 bool judge(int x) { 10 int s = 0; 11 for (int i = 1; i < C;i++) { 12 int ctr = s+1; 13 while (ctr < N && (a[ctr]-a[s] < x)) { 14 ctr++; 15 } 16 if (ctr==N) { 17 return false; 18 } 19 s = ctr; 20 } 21 return
不同的枚举方法,效率完全不同。值得记录一下! 1 #include <cstdio> 2 #include <cstring> 3 int t, a, b, c, n, cas = 0, count = 0; 4 int cnt[30000000]; 5 void pre() { 6 count = 0; 7 memset(cnt, 0, sizeof(cnt)); 8 9 for (a = 1; a <= 30000000; a++) { 10 for (c = 1; c < a; c++) { 11 if (a%c == 0 && ((a-c)^a)==c) { 12 count++; 13 } 14 } 15 cnt[a-1] = count; 16 } 17 18 }
这种题目最重要的是思路了清晰 1 #include <cstdio> 2 #include <cstring> 3 const int maxn = 100005;//sqrt(n)+1 is enough 4 5 int fac[100][2]; 6 int fac_c[100]; 7 int a[maxn]; 8 void factor(int m) { 9 int& num = fac[0][0]; 10 num = 0; 11 for (int i = 2; i*i <= m; i++) { 12 if(m%i == 0) { 13 fac[++num][0] = i; 14 fac[num][1] = 0; 15 do { 16 fac[num][1]++; 17 m/= i; 18 } while(m%i == 0); 19 } 20 } 21 if (m > 1) { 22
类名 类名应该是名词, 描述对象。应该按照驼峰式写法,即只有每个单词首字母大写。 接口名称 接口名称应该是形容词,描述功能。应该以“able”、“ible”结尾,否则应该是名词。通常遵循和类名写相同的大小约定
使用多个开发工具自后,会发现,每个开发工具的快捷键或多或少有些差异。但是幸好快捷键一般都是可以定制的。所以决定以Sublime为参照,来设置如Eclipse之类的IDE,当然了,不是全部修改,遇到一个
1.实现Runnable接口 1 import java.util.Random; 2 3 4 public class PrintTask implements Runnable{ 5 private final int sleepTime; 6 private final String taskName; 7 private final static Random generator = new Random(); 8 9 10 public PrintTask(String name) { 11 taskName = name; 12 sleepTime = generator.nextInt(5000); 13 } 14 15 @Override 16 public void run() { 17 try { 18 System.out.printf("%s going to Sleep for %d milliseconds.\n", 19 taskName, sleepTime); 20 Thread.sleep(sleepTime); 21 } catch (InterruptedException e) { 22 System.out.printf("%s %s\n", taskName, "terminated prematurely" + 23 "
Eclipse默认只有在出现 “.”时才进行代码提示,更改方法为: 即把“.”改为“.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”,表示输入任
1.除法(Division, UVa 725) #include <cstdio> #include <cstring> bool isOk(int a, int b){ char buff[20]; int visited[15]; memset(visited, 0, sizeof(visited)); sprintf(buff, "%05d%05d", a, b); for (int i =0; i < 10; i++){ int temp = buff[i] - '0'; if (0 == visited[temp]){ visited[temp]++; } else { return false; } } return true; } int main(void){ int N, cnt = 0; bool flag = false; for (;scanf("%d", &N) && N;){ if (cnt > 0){ printf("\n"); } cnt++; flag = false; for (int i = 1234; i<
由于需要在pdf文件上做标记,所以自带的文档查看器根本满足了需求,之前去网上查了查,Okular评价挺高,就安装了一个,确实能基本满足我的需求,但是 1.界面感觉还是不太友好,书签栏一直在那。 2.而且,
不及之前重装了一次系统,导致要重新搭建android开发环境,但是在启动AVD时queue遇到了这个问题 androidstudio中看到的是这个样子 大概查了一下,应该是创建虚拟机是选择的cpu构架与有