网站建设域名杭州网站制作多少钱
网站建设域名,杭州网站制作多少钱,网店美工与视觉设计,仿淘宝php c2c电子商务网站模板D - Square Pair
题目大意
给一长为的数组#xff0c;问有多少对#xff0c;两者相乘为非负整数完全平方数
解题思路
一个数除以其能整除的最大的完全平方数#xff0c;看前面有多少个与其余数相同的数#xff0c;两者乘积满足条件#xff08;已经是完全平方数的部分无…D - Square Pair
题目大意
给一长为的数组问有多少对两者相乘为非负整数完全平方数
解题思路
一个数除以其能整除的最大的完全平方数看前面有多少个与其余数相同的数两者乘积满足条件已经是完全平方数的部分无用对于0特判与%0区分开 import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.Vector;public class Main{static long md(long)998244353;static long LinfLong.MAX_VALUE/2;static int infInteger.MAX_VALUE/2;public static void main(String[] args) throws IOException{AReader inputnew AReader();PrintWriter out new PrintWriter(new OutputStreamWriter(System.out));int ninput.nextInt();int[] anew int[n1];HashMapInteger, Integer hsnew HashMapInteger, Integer();long ans0;for(int i1;in;i) {a[i]input.nextInt();if(a[i]0) {continue;}int ta[i];int y(int)Math.sqrt(a[i]);while(y0) {int zy*y;if(t%z0) {t/z;break;}y--;}if(hs.get(t)!null) {int phs.get(t);ansp;hs.put(t, p1);}else {hs.put(t, 1);}}int zero0;for(int i1;in;i) {if(a[i]0) {ansi-1;zero;}else {anszero;}}out.print(ans);out.flush();out.close();}//System.out.println();//out.println();//String oabcdefghijklmnopqrstuvwxyz;//char[] opo.toCharArray();staticclass AReader{ BufferedReader bf;StringTokenizer st;BufferedWriter bw;public AReader(){bfnew BufferedReader(new InputStreamReader(System.in));stnew StringTokenizer();bwnew BufferedWriter(new OutputStreamWriter(System.out));}public String nextLine() throws IOException{return bf.readLine();}public String next() throws IOException{while(!st.hasMoreTokens()){stnew StringTokenizer(bf.readLine());}return st.nextToken();}public char nextChar() throws IOException{//确定下一个token只有一个字符的时候再用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 byte nextByte() throws IOException{return Byte.parseByte(next());}public short nextShort() throws IOException{return Short.parseShort(next());}public BigInteger nextBigInteger() throws IOException{return new BigInteger(next());}public void println() throws IOException {bw.newLine();}public void println(int[] arr) throws IOException{for (int value : arr) {bw.write(value );}println();}public void println(int l, int r, int[] arr) throws IOException{for (int i l; i r; i ) {bw.write(arr[i] );}println();}public void println(int a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}public void print(int a) throws IOException{bw.write(String.valueOf(a));}public void println(String a) throws IOException{bw.write(a);bw.newLine();}public void print(String a) throws IOException{bw.write(a);}public void println(long a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}public void print(long a) throws IOException{bw.write(String.valueOf(a));}public void println(double a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}public void print(double a) throws IOException{bw.write(String.valueOf(a));}public void print(char a) throws IOException{bw.write(String.valueOf(a));}public void println(char a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}}
} E - Last Train
题目大意 个点条边每条边有信息 表示时刻有代价为的路径 问每个点到的最长距离
解题思路 单一汇点多源点反向建图若当前时间为则到下一个点的时间为则下一点最晚出发的时间为其等差数列中最大的小于的时刻由于有最晚出发时间的限制所以不会有走环的情况
import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.Vector;public class Main{static long md(long)998244353;static long LinfLong.MAX_VALUE/2;static int infInteger.MAX_VALUE/2;staticclass Edge{int fr,to,nxt;long l,d,k,c;public Edge(int u,int v,long L,long D,long K,long C) {fru;tov;lL;dD;cC;kK;}}static Edge[] e;static int[] head;static int cnt;static void addEdge(int fr,int to,long l,long d,long k,long c) {cnt;e[cnt]new Edge(fr, to, l, d, k, c);e[cnt].nxthead[fr];head[fr]cnt;}static class Node{int x;long dis;public Node(int X,long D) {xX;disD;}}public static void main(String[] args) throws IOException{AReader inputnew AReader();PrintWriter out new PrintWriter(new OutputStreamWriter(System.out));int ninput.nextInt();int minput.nextInt();enew Edge[m1];headnew int[n1];cnt0;for(int i1;im;i) {long linput.nextLong();long dinput.nextLong();long kinput.nextLong();long cinput.nextLong();int uinput.nextInt();int vinput.nextInt();addEdge(v, u, l, d, k, c);}PriorityQueueNode qnew PriorityQueueNode((o1,o2)-{if(o2.dis-o1.dis0)return 1;else if(o2.dis-o1.dis0)return -1;else return 0;});long[] disnew long[n1];Arrays.fill(dis, -1);dis[n]Linf;q.add(new Node(n, Linf));while(!q.isEmpty()) {Node nowq.peek();q.poll();int xnow.x;if(x!ndis[x]now.dis)continue;dis[x]now.dis;for(int ihead[x];i0;ie[i].nxt) {int ve[i].to;long ce[i].c;long maydis[x]-c;long le[i].l;long de[i].d;long ke[i].k;if(mayl) {maylMath.min((may-l)/d, k-1)*d;q.add(new Node(v, may));}}}for(int i1;in;i) {if(dis[i]-1) {out.println(Unreachable);}else out.println(dis[i]);}out.flush();out.close();}//System.out.println();//out.println();staticclass AReader{ BufferedReader bf;StringTokenizer st;BufferedWriter bw;public AReader(){bfnew BufferedReader(new InputStreamReader(System.in));stnew StringTokenizer();bwnew BufferedWriter(new OutputStreamWriter(System.out));}public String nextLine() throws IOException{return bf.readLine();}public String next() throws IOException{while(!st.hasMoreTokens()){stnew StringTokenizer(bf.readLine());}return st.nextToken();}public char nextChar() throws IOException{//确定下一个token只有一个字符的时候再用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 byte nextByte() throws IOException{return Byte.parseByte(next());}public short nextShort() throws IOException{return Short.parseShort(next());}public BigInteger nextBigInteger() throws IOException{return new BigInteger(next());}public void println() throws IOException {bw.newLine();}public void println(int[] arr) throws IOException{for (int value : arr) {bw.write(value );}println();}public void println(int l, int r, int[] arr) throws IOException{for (int i l; i r; i ) {bw.write(arr[i] );}println();}public void println(int a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}public void print(int a) throws IOException{bw.write(String.valueOf(a));}public void println(String a) throws IOException{bw.write(a);bw.newLine();}public void print(String a) throws IOException{bw.write(a);}public void println(long a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}public void print(long a) throws IOException{bw.write(String.valueOf(a));}public void println(double a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}public void print(double a) throws IOException{bw.write(String.valueOf(a));}public void print(char a) throws IOException{bw.write(String.valueOf(a));}public void println(char a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}}
}
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/86989.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!