Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 63df8b3

Browse files
authored
Add files via upload
1 parent a7198ed commit 63df8b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+24199
-0
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import java.util.*;
2+
public class Main1_Heist {
3+
public static void main(String[] args) {
4+
ArrayList<Integer> a=new ArrayList<Integer>();
5+
Scanner sc=new Scanner(System.in);
6+
int n=Integer.parseInt(sc.nextLine());
7+
for(int i=0;i<n;i++) {
8+
a.add(sc.nextInt());
9+
}
10+
a.sort(null);
11+
int s=0;
12+
for(int i=0;i<(n-1);i++) {
13+
s+=(a.get(i+1)-a.get(i)-1);
14+
}
15+
System.out.println(s);
16+
}
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.util.Scanner;
2+
3+
public class Main2_TV_Buying {
4+
public static long gcd(long a, long b)
5+
{
6+
if (b == 0)
7+
return a;
8+
return gcd(b, a % b);
9+
}
10+
public static void main(String[] args) {
11+
Scanner sc=new Scanner(System.in);
12+
long a=sc.nextLong();
13+
long b=sc.nextLong();
14+
long x=sc.nextLong();
15+
long y=sc.nextLong();
16+
long g=gcd(x,y);
17+
System.out.println(Long.min((long) a/(x/g), (long) b/(y/g)));
18+
}
19+
20+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.util.Scanner;
2+
3+
public class Main3_Pythgorean_Triple_finder {
4+
public static int div(long n) {
5+
long t;
6+
for(int i=0;i<500;i++) {
7+
t=n/(long) (Math.pow((double) n,(double) i));
8+
if((t&1)==0) {
9+
return i;
10+
}
11+
}
12+
return n;
13+
}
14+
public static void main(String[] args) {
15+
// TODO Auto-generated method stub
16+
Scanner sc=new Scanner(System.in);
17+
long a=sc.nextLong();
18+
sc.close();
19+
int even=1;
20+
if((a & 1)==0) {
21+
int r;
22+
even=div(a);
23+
r=a/(long) (Math.pow((double) a,(double) even))
24+
}
25+
26+
27+
}
28+
29+
}

javausaco - Copy/Cryptography/M6972593.txt

Lines changed: 20990 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.
Binary file not shown.
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
2+
100000000003
3+
100000000019
4+
100000000057
5+
100000000063
6+
100000000069
7+
100000000073
8+
100000000091
9+
100000000103
10+
100000000129
11+
100000000171
12+
100000000183
13+
100000000193
14+
100000000211
15+
100000000223
16+
100000000237
17+
100000000253
18+
100000000283
19+
100000000319
20+
100000000363
21+
100000000367
22+
100000000379
23+
100000000393
24+
100000000403
25+
100000000411
26+
100000000417
27+
100000000427
28+
100000000447
29+
100000000487
30+
100000000519
31+
100000000567
32+
100000000579
33+
100000000621
34+
100000000631
35+
100000000637
36+
100000000669
37+
100000000699
38+
100000000703
39+
100000000721
40+
100000000739
41+
100000000747
42+
100000000801
43+
100000000817
44+
100000000819
45+
100000000861
46+
100000000901
47+
100000000943
48+
100000000951
49+
100000001009
50+
100000001099
51+
100000001111
52+
100000001149
53+
100000001201
54+
100000001209
55+
100000001237
56+
100000001239
57+
100000001249
58+
100000001267
59+
100000001287
60+
100000001291
61+
100000001317
62+
100000001347
63+
100000001363
64+
100000001377
65+
100000001389
66+
100000001399
67+
100000001467
68+
100000001489
69+
100000001509
70+
100000001513
71+
100000001551
72+
100000001557
73+
100000001567
74+
100000001641
75+
100000001659
76+
100000001693
77+
100000001729
78+
100000001771
79+
100000001807
80+
100000001831
81+
100000001837
82+
100000001839
83+
100000001863
84+
100000001909
85+
100000001921
86+
100000001923
87+
100000001939
88+
100000001957
89+
100000001989
90+
100000002017
91+
100000002031
92+
100000002041
93+
100000002059
94+
100000002061
95+
100000002097
96+
100000002103
97+
100000002181
98+
100000002191
99+
100000002199
100+
100000002229
101+
100000002251
102+
100000002299
103+
100000002313
104+
100000002317
105+
100000002353
106+
100000002359
107+
100000002373
108+
100000002413
109+
100000002497
110+
100000002499
111+
100000002503
112+
100000002511
113+
100000002539
114+
100000002587
115+
100000002617
116+
100000002677
117+
100000002689
118+
100000002731
119+
100000002757
120+
100000002827
121+
100000002847
122+
100000002863
123+
100000002889
124+
100000002911
125+
100000002913
126+
100000002941
127+
100000002943
128+
100000002953
129+
100000003039
130+
100000003067
131+
100000003069
132+
100000003087
133+
100000003097
134+
100000003163
135+
100000003211
136+
100000003223
137+
100000003241
138+
100000003249
139+
100000003277
140+
100000003303
141+
100000003319
142+
100000003361
143+
100000003373
144+
100000003379
145+
100000003381
146+
100000003447
147+
100000003457
148+
100000003471
149+
100000003517
150+
100000003559
151+
100000003583
152+
100000003591
153+
100000003627
154+
100000003657
155+
100000003661
156+
100000003699
157+
100000003709
158+
100000003757
159+
100000003759
160+
100000003787
161+
100000003813
162+
100000003853
163+
100000003867
164+
100000003897
165+
100000003921
166+
100000003951
167+
100000003997
168+
100000004021
169+
100000004053
170+
100000004099
171+
100000004107
172+
100000004171
173+
100000004177
174+
100000004207
175+
100000004267
176+
100000004333
177+
100000004407
178+
100000004437
179+
100000004449
180+
100000004471
181+
100000004483
182+
100000004501
183+
100000004521
184+
100000004539
185+
100000004591
186+
100000004653
187+
100000004677
188+
100000004707
189+
100000004719
190+
100000004749
191+
100000004761
192+
100000004809
193+
100000004827
194+
100000004837
195+
100000004843
196+
100000004849
197+
100000004861
198+
100000004903
199+
100000004917
200+
100000004953
201+
100000004987
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package RSA;
2+
import java.util.*;
3+
import java.math.*;
4+
public class Crypto {
5+
public static char dc(int i) {
6+
return (char) i;
7+
8+
}
9+
public static int ec(char i) {
10+
return (int) i;
11+
}
12+
public static BigInteger[] encrypt(String s, BigInteger n, BigInteger e) {
13+
char[] sa=s.toCharArray();
14+
BigInteger[] out=new BigInteger[sa.length];
15+
int temp;
16+
for(int i=0;i<sa.length;i++) {
17+
temp=ec(sa[i]);
18+
out[i]=BigInteger.valueOf(temp).modPow(e, n);
19+
}
20+
21+
return out;
22+
}
23+
public static void go(BigInteger[] k) {
24+
for(BigInteger a:k) {
25+
System.out.print(a+",");
26+
27+
}
28+
}
29+
public static void main(String[] args) {
30+
System.out.println("Encrypt or decrypt use d or e");
31+
final BigInteger ONE=BigInteger.ONE;
32+
Scanner sc=new Scanner(System.in);
33+
String choice=sc.nextLine();
34+
BigInteger n,e;
35+
if(choice.equals("d")) {
36+
System.out.println("Enter d");
37+
BigInteger d=sc.nextBigInteger();
38+
System.out.println("Enter n and e");
39+
n=sc.nextBigInteger();
40+
e=sc.nextBigInteger();
41+
}else if(choice.equals("e")) {
42+
System.out.println("Enter n and e and then your plaintext");
43+
n=sc.nextBigInteger();
44+
e=sc.nextBigInteger();
45+
System.out.println("Please enter your plaintext");
46+
go(encrypt(sc.nextLine(),n,e));
47+
}else {
48+
System.out.println("Invalid choice, terminating");
49+
System.exit(1);
50+
51+
}//91,5,29
52+
}
53+
54+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package RSA;
2+
import java.math.BigInteger;
3+
import java.util.*;
4+
5+
public class Test1 {
6+
7+
public static void main(String[] args) {
8+
// TODO Auto-generated method stub
9+
boolean customprime=true;
10+
Scanner sc=new Scanner(System.in);
11+
System.out.println("P:");
12+
BigInteger p=sc.nextBigInteger();
13+
System.out.println("Q:");
14+
BigInteger q=sc.nextBigInteger();
15+
System.out.println("Calculating public key/encryption key");
16+
BigInteger n=p.multiply(q);
17+
BigInteger e=(p.subtract(BigInteger.ONE)).multiply(q.subtract(BigInteger.ONE)).subtract(BigInteger.ONE);
18+
if(customprime) {
19+
System.out.println("Custom primes is enabled. Please manually enter a relativley prime number to "+(e.add(BigInteger.ONE)));
20+
e=sc.nextBigInteger();
21+
}
22+
System.out.println("Your public key is "+n+ ","+e);
23+
System.out.println("Calculating private key/decryption key");
24+
BigInteger i=p.subtract(BigInteger.ONE).multiply(q.subtract(BigInteger.ONE));
25+
boolean found=false;
26+
for(BigInteger d=BigInteger.ONE;!(found);d=d.add(BigInteger.ONE)) {
27+
if(e.multiply(d).mod(i).equals(BigInteger.ONE)) {
28+
System.out.println("It is:"+d);
29+
found=true;
30+
}else {
31+
//System.out.println(d+","+i+","+e);
32+
//System.out.println(e.multiply(d).mod(i));
33+
}
34+
//if(d.toString().equals("100")) {break;}
35+
}
36+
System.out.println("You also need the public key for decrypting");
37+
38+
}
39+
40+
}
41+
/*
42+
* Sample numbers
43+
* 20,988,936,657,440,586,486,151,264,256,610,222,593,863,921
44+
* 170,141,183,460,469,231,731,687,303,715,884,105,727
45+
* 12027524255478748885956220793734512128733387803682075433653899983955179850988797899869146900809131611153346817050832096022160146366346391812470987105415233
46+
* 12131072439211271897323671531612440428472427633701410925634549312301964373042085619324197365322416866541017057361365214171711713797974299334871062829803541
47+
*/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Java
2+
Useful library for usaco and other purposes.
3+
. Use releases when possible otherwise download usacotools.java.
4+
# Release dates and more
5+
Find release dates at https://javaarchive.github.io/Java/. Moved to https://github.com/javaarchive/Java/wiki
379 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
public class SimpleSorter {
3+
4+
public static void main(String[] args) {
5+
// TODO Auto-generated method stub
6+
7+
}
8+
9+
}
230 Bytes
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
public interface Sorter {
3+
public int SortMode=0;
4+
public void sort1();
5+
public int[] sort2();
6+
public String[] sort3();
7+
8+
}
585 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)