25 篇文章 1 订阅

# 3.8

import java.util.*;
import java.math.*;
import java.io.*;

public class Main {

static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

public static boolean check(int x) {
while (x > 0) {
int mod = x % 10;
if (mod == 2 || mod == 4) return false;
x /= 10;
}
return true;
}

public static void main(String[] args) throws Exception {

//    	int cnt = 0;
//    	for (int i = 1; i < 2019; i++) {
//    		if (!check(i)) continue;
//    		for (int j = i + 1; j < 2019; j++) {
//    			if (!check(j)) continue;
//    			for (int k = j + 1; k < 2019; k++) {
//    				if (check(k) && i + j + k == 2019) cnt++;
//    			}
//    		}
//    	}
//    	out.println(cnt);
out.println(40785);

out.flush();
in.close();
}
}


import java.util.*;
import java.math.*;
import java.io.*;

public class Main {

static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

public static boolean check(int i, int j) {
int num = i * 10000 + 600 + j;
return num % 2012 == 0 && num % 3 == 0 && num % 12 == 0;
}

public static void main(String[] args) throws Exception {

//    	for (int i = 2011; i >= 1900; i--) {
//    		for (int j = 1; j <= 30; j++) {
//    			if (check(i, j)) {
//    				out.println(i + " " + j);
//    				break;
//    			}
//    		}
//    	}

out.println("19550604");

out.flush();
in.close();
}
}


import java.util.*;
import java.math.*;
import java.io.*;

public class Main {

static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

public static void main(String[] args) throws Exception {

int n = Integer.parseInt(in.readLine());
double cnt1 = 0, cnt2 = 0;
for (int i = 0; i < n; i++) {
int t = Integer.parseInt(in.readLine());
if (t >= 60) cnt1++;
if (t >= 85) cnt2++;
}
out.println(Math.round((cnt1 / n * 100)) + "%");
out.println(Math.round((cnt2 / n * 100)) + "%");

out.flush();
in.close();
}
}


dp，题目已经给了状态转移方程了

f[i] 为从起点出发到点 i 的最大价值，从可以一步到达 i 点的所有点中找到价值最大的即可

f[i] = max(f[i], f[j] + v[i])

import java.util.*;
import java.math.*;
import java.io.*;

public class Main {

static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

static int N = (int)1e4 + 10, n;
static int[] a = new int[N], f = new int[N];

public static int getDn(int x) {
x = n - x;
if (x == 1) return 1;
int p = 2;
while (p * p <= x) {
while (x % p == 0) {
return p;
}
p++;
}
return x;
}

public static void main(String[] args) throws Exception {

String[] s = in.readLine().split(" ");
for (int i = 1; i <= n; i++) {
a[i] = Integer.parseInt(s[i - 1]);
}
Arrays.fill(f, -0x3f3f3f3f);
f[1] = a[1];

for (int i = 1; i <= n; i++) {
int st = i + 1, ed = Math.min(n, getDn(i) + i);
for (int j = st; j <= ed; j++) f[j] = Math.max(f[j], f[i] + a[j]);
}

out.println(f[n]);

out.flush();
in.close();
}
}

• 2
点赞
• 0
收藏
觉得还不错? 一键收藏
• 打赏
• 0
评论
07-28
04-02
05-20
02-15
11-05
04-01
04-01

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

⠀One0ne

¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。