当前位置: 首页 > wzjs >正文

做网站建设的联系电话沈阳seo团队

做网站建设的联系电话,沈阳seo团队,自己做服装搭配的网站,松江醉白池网站建设目录 题目地址 做题情况 A 题 B 题 C 题 D 题 E 题 F 题 牛客竞赛主页 题目地址 牛客竞赛_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ 做题情况 A 题 输出两个不是同一方位的字符中的任意一个就行 import java.io.*; import java.math.*; import java…

目录

题目地址

做题情况

A 题

B 题

C 题

D 题

E 题

F 题

牛客竞赛主页

题目地址

牛客竞赛_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ

做题情况

A 题

输出两个不是同一方位的字符中的任意一个就行

import java.io.*;
import java.math.*;
import java.util.*;public class Main {static IOS sc=new IOS();static final int MOD = 998244353;public static void solve() throws IOException {char a=sc.nextChar();if(a=='U'||a=='D') {dduoln('L');}else {dduoln('U');}}public static void main(String[] args) throws Exception {int t = 1;
//        t = sc.nextInt();while (t-- > 0) {solve();}}static <T> void dduo(T t) {System.out.print(t);}static <T> void dduoln(T t) {System.out.println(t);}}class IOS{BufferedReader bf;StringTokenizer st;BufferedWriter bw;public IOS(){bf=new BufferedReader(new InputStreamReader(System.in));st=new StringTokenizer("");bw=new BufferedWriter(new OutputStreamWriter(System.out));}public String nextLine() throws IOException{return bf.readLine();}public String next() throws IOException{while(!st.hasMoreTokens()){st=new StringTokenizer(bf.readLine());}return st.nextToken();}public char nextChar() throws IOException{return next().charAt(0);}public int nextInt() throws IOException{return Integer.parseInt(next());}public long nextLong() throws IOException{return Long.parseLong(next());}public double nextDouble() throws IOException{return Double.parseDouble(next());}public float nextFloat() throws IOException{return Float.parseFloat(next());}public BigInteger nextBigInteger() throws IOException{return new BigInteger(next());}public BigDecimal nextDecimal() throws IOException{return new BigDecimal(next());}
}

B 题

可以稍微贪心一下

构造 1 2 1 2 1 2 1 2 1 2

import java.io.*;
import java.math.*;
import java.util.*;public class Main {static IOS sc=new IOS();static final int MOD = 998244353;public static void solve() throws IOException {int n=sc.nextInt();for(int i=0;i<n;i++) {if(i%2==0) {dduo(1+" ");}else {dduo(2+" ");}}dduoln("");}public static void main(String[] args) throws Exception {int t = 1;t = sc.nextInt();while (t-- > 0) {solve();}}static <T> void dduo(T t) {System.out.print(t);}static <T> void dduoln(T t) {System.out.println(t);}}class IOS{BufferedReader bf;StringTokenizer st;BufferedWriter bw;public IOS(){bf=new BufferedReader(new InputStreamReader(System.in));st=new StringTokenizer("");bw=new BufferedWriter(new OutputStreamWriter(System.out));}public String nextLine() throws IOException{return bf.readLine();}public String next() throws IOException{while(!st.hasMoreTokens()){st=new StringTokenizer(bf.readLine());}return st.nextToken();}public char nextChar() throws IOException{return next().charAt(0);}public int nextInt() throws IOException{return Integer.parseInt(next());}public long nextLong() throws IOException{return Long.parseLong(next());}public double nextDouble() throws IOException{return Double.parseDouble(next());}public float nextFloat() throws IOException{return Float.parseFloat(next());}public BigInteger nextBigInteger() throws IOException{return new BigInteger(next());}public BigDecimal nextDecimal() throws IOException{return new BigDecimal(next());}
}

C 题

通过打表发现

1212/12

123123/123

112112/112

都能除尽

所以 我 直接 (str+""+str) /str 求出结果

import java.io.*;
import java.math.*;
import java.util.*;public class Main {static IOS sc=new IOS();static final int MOD = 998244353;public static void solve() throws IOException {String str=sc.next();BigInteger b=new BigInteger(str+str);BigInteger c=new BigInteger(str);dduoln(b.divide(c));}public static void main(String[] args) throws Exception {int t = 1;t = sc.nextInt();while (t-- > 0) {solve();}}static <T> void dduo(T t) {System.out.print(t);}static <T> void dduoln(T t) {System.out.println(t);}}class IOS{BufferedReader bf;StringTokenizer st;BufferedWriter bw;public IOS(){bf=new BufferedReader(new InputStreamReader(System.in));st=new StringTokenizer("");bw=new BufferedWriter(new OutputStreamWriter(System.out));}public String nextLine() throws IOException{return bf.readLine();}public String next() throws IOException{while(!st.hasMoreTokens()){st=new StringTokenizer(bf.readLine());}return st.nextToken();}public char nextChar() throws IOException{return next().charAt(0);}public int nextInt() throws IOException{return Integer.parseInt(next());}public long nextLong() throws IOException{return Long.parseLong(next());}public double nextDouble() throws IOException{return Double.parseDouble(next());}public float nextFloat() throws IOException{return Float.parseFloat(next());}public BigInteger nextBigInteger() throws IOException{return new BigInteger(next());}public BigDecimal nextDecimal() throws IOException{return new BigDecimal(next());}
}

D 题

模拟题

我的解法是先求出位于 (1,1)(2,2)(3,3)(4,4) 点要多少步

不难是 9 ,25, 49, 81...步

我们发现是奇数的平方

所以先求出要求的这个点是从哪个开始的 即(a,a)

然后算到(a,a)一共要多少步

求出还剩多少步

剩下了多少步然后是 在上面走 在右边走 在下面走 在左边走 在上面走 根据 a 可以算出每条边各需要多少步

在每条边上更新剩下要走的步数

即可求出

import java.io.*;
import java.math.*;
import java.util.*;public class Main {static IOS sc=new IOS();static final int MOD = 998244353;public static void solve() throws IOException {long n=sc.nextLong();long ii=0;ii=(long) Math.sqrt(n);ii+=1;if(ii%2==0) {ii++;}ii-=2;
//    	dduoln(ii);
//    	
//    	for(int i=1;i<=1e9;i+=2) {
//    		if(i*i>n) {
//    			ii=i-2;
//    			break;
//    		}
//    	}
//    	dduoln(ii);long a=(ii-1)/2; // 起始位置(a,a)
//    	dduoln(a+" "+a);long ans=(n-ii*ii); // 剩下多少步
//    	dduoln(ans);if(ans==0) {dduoln(a+" "+a);return;}else if(ans==1) {dduoln( (a+1) +" "+a);return;}long duanbian=a*2+1;long changbian=(a+1)*2;ans-=1;// 右if(ans<duanbian) {dduoln((a+1)+" "+(a-ans));return;}ans-=duanbian;// 下if(ans<changbian) {dduoln((a+1-ans)+" "+(-a-1));return;}ans-=changbian;// 左if(ans<changbian) {dduoln((-a-1)+" "+(-a-1+ans));return;}ans-=changbian;dduoln((-a-1+ans)+" "+(a+1));}public static void main(String[] args) throws Exception {int t = 1;t = sc.nextInt();while (t-- > 0) {solve();}}}class IOS{BufferedReader bf;StringTokenizer st;BufferedWriter bw;public IOS(){bf=new BufferedReader(new InputStreamReader(System.in));st=new StringTokenizer("");bw=new BufferedWriter(new OutputStreamWriter(System.out));}public String nextLine() throws IOException{return bf.readLine();}public String next() throws IOException{while(!st.hasMoreTokens()){st=new StringTokenizer(bf.readLine());}return st.nextToken();}public char nextChar() throws IOException{return next().charAt(0);}public int nextInt() throws IOException{return Integer.parseInt(next());}public long nextLong() throws IOException{return Long.parseLong(next());}public double nextDouble() throws IOException{return Double.parseDouble(next());}public float nextFloat() throws IOException{return Float.parseFloat(next());}public BigInteger nextBigInteger() throws IOException{return new BigInteger(next());}public BigDecimal nextDecimal() throws IOException{return new BigDecimal(next());}
}

E 题

动态规划

首先知道了 第一次可以到达 1 6

第二次可以到达 2 12

第三次可以到达 3 18

以此类推

维护一个 dp 数组 代表的是到达当前位置获取到的最大贡献值

再在每次运动 都要 for(1-6) 找一下这六步对 dp 数组的更新

需要注意的是 不要访问到数组外面去

最后找出 dp 数组中的最大值就行

import java.io.*;
import java.math.*;
import java.util.*;public class Main {static IOS sc=new IOS();static final int MOD = 998244353;public static void solve() throws IOException {int n = sc.nextInt();  // n个数int k = sc.nextInt();  // 两次int[] a = new int[n]; // 每个数的数值for (int i = 0; i < n; i++) {a[i] = sc.nextInt();}long[] dp = new long[n + 1];Arrays.fill(dp, Long.MIN_VALUE);dp[0] = 0;for (int step = 1; step <= k; step++) {long[] current = new long[n + 1];Arrays.fill(current, Long.MIN_VALUE);// 求出当前可到达的位置int xmin = step - 1;int xmax = Math.min(6 * (step - 1), n); 
//            dduoln(xmin+" "+xmax);for (int x = xmin; x <= xmax; x++) {for (int d = 1; d <= 6; d++) {int j = x + d;if (j > n) {continue;}current[j]=Math.max(current[j],dp[x] + a[j - 1]);}}dp = current;}int maxfoot = Math.min(6 * k, n); // 最大步数long max = Long.MIN_VALUE;for (int i = k; i <= maxfoot; i++) {max=Math.max(dp[i], max);}dduoln(max);}public static void main(String[] args) throws Exception {int t = 1;
//        t = sc.nextInt();while (t-- > 0) {solve();}}static <T> void dduo(T t) {System.out.print(t);}static <T> void dduoln(T t) {System.out.println(t);}}class IOS{BufferedReader bf;StringTokenizer st;BufferedWriter bw;public IOS(){bf=new BufferedReader(new InputStreamReader(System.in));st=new StringTokenizer("");bw=new BufferedWriter(new OutputStreamWriter(System.out));}public String nextLine() throws IOException{return bf.readLine();}public String next() throws IOException{while(!st.hasMoreTokens()){st=new StringTokenizer(bf.readLine());}return st.nextToken();}public char nextChar() throws IOException{return next().charAt(0);}public int nextInt() throws IOException{return Integer.parseInt(next());}public long nextLong() throws IOException{return Long.parseLong(next());}public double nextDouble() throws IOException{return Double.parseDouble(next());}public float nextFloat() throws IOException{return Float.parseFloat(next());}public BigInteger nextBigInteger() throws IOException{return new BigInteger(next());}public BigDecimal nextDecimal() throws IOException{return new BigDecimal(next());}
}

F 题

BFS

import java.io.*;
import java.math.*;
import java.util.*;public class Main {static IOS sc=new IOS();static final int MOD = 998244353;public static void solve() throws IOException {int startX=0, startY=0, endX=0, endY=0;int n = sc.nextInt();int m = sc.nextInt();int h = sc.nextInt();char[][] grid = new char[n + 1][m + 1];  int[][] minTime = new int[n + 1][m + 1];for (int i = 0; i <= n; i++) {Arrays.fill(minTime[i], Integer.MAX_VALUE);}for (int i = 1; i <= n; i++) {String s = sc.next();for (int j = 1; j <= m; j++) {grid[i][j] = s.charAt(j-1);if (grid[i][j] == '*') { // 记录水源的位置startX = i;startY = j;} else if (grid[i][j] == '%') { // 记录终点的位置endX = i;endY = j;}}}int ans=0;PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> a[0] - b[0]);pq.offer(new int[]{0, startX, startY, 1});while (!pq.isEmpty()) {int[] cur = pq.poll();int time = cur[0], x = cur[1], y = cur[2], state = cur[3];if (x == endX && y == endY) { // 到达了终点ans=time;break;}if (state == 0 && minTime[x][y] <= time) continue;minTime[x][y] = Math.min(minTime[x][y], time);if (x + 1 <= n) {if (grid[x + 1][y] == '#') {if (y - 1 >= 1 && grid[x][y - 1] != '#') {pq.offer(new int[]{time + 1, x, y - 1, 0});}if (y + 1 <= m && grid[x][y + 1] != '#') {pq.offer(new int[]{time + 1, x, y + 1, 0});}if (state == 1) {pq.offer(new int[]{time + h + 1, x + 1, y, 1});}}else {pq.offer(new int[]{time + 1, x + 1, y, 1});}}ans=Integer.MAX_VALUE;}dduoln(ans == Integer.MAX_VALUE ? -1 : ans);}public static void main(String[] args) throws Exception {int t = 1;
//        t = sc.nextInt();while (t-- > 0) {solve();}}static <T> void dduo(T t) {System.out.print(t);}static <T> void dduoln(T t) {System.out.println(t);}}class Node implements Comparable<Node> {int x, y, nowT, abi;public Node(int x, int y, int nowT, int abi) {this.x = x;this.y = y;this.nowT = nowT;this.abi = abi;}@Overridepublic int compareTo(Node other) {return Integer.compare(other.nowT, this.nowT); // 按照 nowT 值进行比较,形成最大堆}
}class IOS{BufferedReader bf;StringTokenizer st;BufferedWriter bw;public IOS(){bf=new BufferedReader(new InputStreamReader(System.in));st=new StringTokenizer("");bw=new BufferedWriter(new OutputStreamWriter(System.out));}public String nextLine() throws IOException{return bf.readLine();}public String next() throws IOException{while(!st.hasMoreTokens()){st=new StringTokenizer(bf.readLine());}return st.nextToken();}public char nextChar() throws IOException{return next().charAt(0);}public int nextInt() throws IOException{return Integer.parseInt(next());}public long nextLong() throws IOException{return Long.parseLong(next());}public double nextDouble() throws IOException{return Double.parseDouble(next());}public float nextFloat() throws IOException{return Float.parseFloat(next());}public BigInteger nextBigInteger() throws IOException{return new BigInteger(next());}public BigDecimal nextDecimal() throws IOException{return new BigDecimal(next());}
}

牛客竞赛主页

她说喜欢是装的的比赛主页

http://www.dtcms.com/wzjs/378514.html

相关文章:

  • 网站备案通过后怎么办seo最新技巧
  • 怎么玩wordpress湖南企业竞价优化服务
  • 徐州高端网站建设搜索大全引擎入口网站
  • 超凡网络网站进入百度app查看
  • 淘宝店的网站建设分析百度网站提交入口网址
  • 广南网站制作建网站
  • 对于网站界面做个电商平台要多少钱
  • 海南省住房公积金管理局地址网站优化seo推广服务
  • 网站建设 天津seo关键词优化培训
  • 沈阳网站关键词优化多少钱小程序开发公司十大排名
  • 用python做网站多吗用asp做的网站
  • 工业b2b网站建设成品网站源码在线看
  • excel做网站页面布局百度查询入口
  • 天蝎网站建设seo查询官网
  • dede多个网站怎么做百度推广首次开户需要多少钱
  • wordpress文字居中网站内容优化方法
  • 网站推广智选刺盾云下拉百度搜索榜单
  • 投资网站php源码百度百科官网登录
  • 帮人做网站犯法sem推广是什么意思
  • 枣庄手机网站建设电话产品推广方法有哪些
  • 灯具网站模板百度手机网页版
  • 北京企业网站模板建站怎么用百度搜索风云榜排名
  • 做网站写个人日志长沙seo外包
  • 网站建设unohacha武汉新闻最新消息
  • 有哪个网站可以做ppt赚钱搜索引擎营销的英文简称
  • 西安网站制作哪家便宜又好自动引流免费app
  • 广州网站推广策划网络整合营销理论案例
  • 广州网站定制开发网站和网页的区别
  • 成都那家网站制作公司好seo优化宣传
  • 手机建行网站广州网络seo优化