Skip to content

Commit 3817662

Browse files
committed
Maths Adhoc, Fast IO
1 parent b4bd347 commit 3817662

File tree

7 files changed

+212
-5
lines changed

7 files changed

+212
-5
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
*.out
2-
*.exe
2+
*.exe
3+
in
4+
*.class
5+
test.*

11723-d.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <iostream>
2+
#include <cmath>
3+
#include <cstdio>
4+
using namespace std;
5+
int main(){
6+
int nstreets, nNumbers;
7+
// Scanner s = new Scanner(System.in);
8+
9+
// nstreets = s.nextInt();
10+
// nNumbers = s.nextInt();
11+
cin >> nstreets >> nNumbers;
12+
int c = 0;
13+
while (nstreets != 0 && nNumbers != 0) {
14+
nstreets -= nNumbers;
15+
// int nAlpha = (int)Math.ceil((double)nstreets / nNumbers);
16+
int nAlpha = ceil(1.0 * nstreets / nNumbers);
17+
18+
printf("Case %d: ", ++c);
19+
20+
if (nAlpha > 26) puts("impossible");
21+
else cout << nAlpha << "\n";
22+
23+
// nstreets = s.nextInt();
24+
// nNumbers = s.nextInt();
25+
cin >> nstreets >> nNumbers;
26+
}
27+
}

11723-d.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.*;
2+
import java.io.*;
3+
public class uva11723_deepak {
4+
public static void main(String[] args) {
5+
//TODO TLE : Slow Input and Output
6+
int nstreets, nNumbers;
7+
// Scanner s = new Scanner(System.in);
8+
FastReader s = new FastReader();
9+
nstreets = s.nextInt();
10+
nNumbers = s.nextInt();
11+
int c = 0;
12+
while (nstreets != 0 && nNumbers != 0) {
13+
nstreets -= nNumbers;
14+
int nAlpha = (int)Math.ceil((double)nstreets / nNumbers);
15+
16+
System.out.printf("Case %d: ", ++c);
17+
18+
if (nAlpha > 26) System.out.println("impossible");
19+
else System.out.println(nAlpha);
20+
21+
nstreets = s.nextInt();
22+
nNumbers = s.nextInt();
23+
}
24+
}
25+
}

11875-d.java

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
import java.util.*;
3+
import java.io.*;
4+
class Main {
5+
// public static void main(){
6+
public static void main(String args[]){
7+
FastReader s = new FastReader();
8+
int n = s.nextInt();
9+
int c = 0;
10+
while(n-- > 0){
11+
int x = s.nextInt();
12+
int i = x / 2 + 1;
13+
int cur, ans = 0;
14+
for(int j = 0; j < x; ++j){
15+
cur = s.nextInt();
16+
--i;
17+
if (i == 0) ans = cur;
18+
}
19+
System.out.printf("Case %d: %d\n", ++c, ans);
20+
}
21+
}
22+
23+
static class FastReader {
24+
BufferedReader br;
25+
StringTokenizer st;
26+
27+
public FastReader() {
28+
br = new BufferedReader(new
29+
InputStreamReader(System.in));
30+
}
31+
32+
String next() {
33+
while (st == null || !st.hasMoreElements()) {
34+
try {
35+
st = new StringTokenizer(br.readLine());
36+
} catch (IOException e) {
37+
e.printStackTrace();
38+
}
39+
}
40+
return st.nextToken();
41+
}
42+
43+
int nextInt() {
44+
return Integer.parseInt(next());
45+
}
46+
47+
long nextLong() {
48+
return Long.parseLong(next());
49+
}
50+
51+
double nextDouble() {
52+
return Double.parseDouble(next());
53+
}
54+
55+
String nextLine() {
56+
String str = "";
57+
try {
58+
str = br.readLine();
59+
} catch (IOException e) {
60+
e.printStackTrace();
61+
}
62+
return str;
63+
}
64+
}
65+
}

INTEST-d.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <iostream>
2+
#include <cstdio>
3+
using namespace std;
4+
int main(){
5+
int n, k, x, c = 0;
6+
cin >> n >> k;
7+
while(n--){
8+
//use scanf for high input
9+
scanf("%d", &x);
10+
if (x % k == 0) ++c;
11+
}
12+
cout << c;
13+
}

INTEST-d.java

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import java.util.*;
2+
import java.io.*;
3+
class INTEST_deepak{
4+
static class FastReader
5+
{
6+
BufferedReader br;
7+
StringTokenizer st;
8+
9+
public FastReader()
10+
{
11+
br = new BufferedReader(new
12+
InputStreamReader(System.in));
13+
}
14+
15+
String next()
16+
{
17+
while (st == null || !st.hasMoreElements())
18+
{
19+
try
20+
{
21+
st = new StringTokenizer(br.readLine());
22+
}
23+
catch (IOException e)
24+
{
25+
e.printStackTrace();
26+
}
27+
}
28+
return st.nextToken();
29+
}
30+
31+
int nextInt()
32+
{
33+
return Integer.parseInt(next());
34+
}
35+
36+
long nextLong()
37+
{
38+
return Long.parseLong(next());
39+
}
40+
41+
double nextDouble()
42+
{
43+
return Double.parseDouble(next());
44+
}
45+
46+
String nextLine()
47+
{
48+
String str = "";
49+
try
50+
{
51+
str = br.readLine();
52+
}
53+
catch (IOException e)
54+
{
55+
e.printStackTrace();
56+
}
57+
return str;
58+
}
59+
}
60+
61+
public static void main(String args[]){
62+
FastReader s = new FastReader();
63+
// Scanner s = new Scanner(System.in);
64+
int n = s.nextInt();
65+
int t = s.nextInt();
66+
int x;
67+
int c = 0;
68+
while(n-- > 0){
69+
x = s.nextInt();
70+
if (x % t == 0) ++c;
71+
}
72+
73+
System.out.printf("%d", c);
74+
}
75+
}

in

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
3 4
2-
1
3-
0
4-
4
1+
2
2+
5 19 17 16 14 12
3+
5 12 14 16 17 18

0 commit comments

Comments
 (0)