"Higher Education Society Cup" the third Fujian Province University student Program design Competition

Source: Internet
Author: User
Tags cas printf stdin strlen time limit valid cmath
a.problem 2102 Solve equation accept:1032 submit:2471
Time limit:1000 mSec Memory limit:32768 KB
problem Description

You are given, positive integers A and B in Base C. For the equation:

A=k*b+d

We know there always existing many non-negative pairs (k, d) that satisfy the equation above. Now on this problem, we want to maximize K.

For example, a= "123" and b= "", c=10. So both A and B is in Base 10. Then we have:

(1) a=0*b+123

(2) a=1*b+23

As we want to maximize K, we finally get one solution: (1, 23)

The range of C is between 2 and +, and we use ' a ', ' B ', ' C ', ' d ', ' e ', ' f ' to represent, one, one, ten,, and Respectiv Ely. Input

The first line of the input contains an integer T (t≤10), indicating the number of the test cases.

Then T-cases, for any case, is 3 positive integers A, B and C (2≤C≤16) in a single line. You can assume this in Base, both A and B are less than 2^31. Output For each test case, the output of the solution "(k,d)" to the equation in Base 10. Sample Input 32BC 33f 16123 101 1 2 Sample Output (0,700) (1,23) (1,0) Source "Higher Education Cup" the third Fujian province College Student Program Design contest
Test instructions: Give you two numbers, they are arbitrary, the binary requirements have been limited to 2 binary and 16 binary, and then solve let A = k* B + d This equation set the largest k value. Problem-Solving ideas: Convert a, b two numbers to decimal (because the title requires the final output of K and D values must be decimal), and then to a% B = d, solve the value of D, then k = (a-d)/B, you can.

#include <queue> #include <cmath> #include <cstdio> #include <string> #include <cstring> #

Include <iostream> #include <algorithm> using namespace std; #pragma COMMENT (linker, "/stack:1024000000,1024000000") #define FIN freopen ("Input.txt", "R", stdin) #define FOUT freopen ("Output.txt", "w", stdout) #define FST First #define SND second typedef __i
Nt64 LL;

typedef pair<int, int> PII;

Const double EPS = 1e-10;
const int MAXN = 1e2 + 5;

const int INF = 0X3F3F3F3F;
int T, N, M;
int C;

Char A[MAXN], B[MAXN];
    int get (char* s) {int t = 1, res = 0, Len = strlen (s);; for (int i = len-1; I >= 0; I--, t *= c) {if (S[i] >= ' A ' && s[i] <= ' z ') res + = (
        S[i]-' a ' + ten) * t;
    else res + = (s[i]-' 0 ') * t;
} return res;
    } int main () {#ifndef Online_judge FIN;
FOUT;
    #endif//Online_judge int cas = 0, res;scanf ("%d", &t);
        while (t--) {scanf ("%s%s%d", A, b, &c);
        int AA = Get (a);
        int bb = get (b);
    printf ("(%d,%d) \ n", aa/bb, aa% BB);
} return 0; }

C.problem 2104 Floor problem accept:1076 submit:1257
Time limit:1000 mSec Memory limit:32768 KB
problem Description

In this problem, we have F (n,x) =floor[n/x]. Here Floor[x] are the biggest integer such that no larger than X. For example, Floor[1.1]=floor[1.9]=1, floor[2.0]=2.

You are given 3 positive integers n, L and R. Print The result of f (n,l) +f (n,l+1) +...+f (n,r), please. Input

The first line of the input contains an integer T (t≤100), indicating the number of the test cases.

Then T-cases, for any case, only 3 integers n, l and R (1≤n, L, r≤10,000, L≤r).  output For each test case, print the result of f (n,l) +f (n,l+1) +...+f (n,r) in a single line.  sample Input 2 3100 2 100100 3  sample Output 0382332  so Urce "Higher Education Cup" the third Fujian University College Students Program Design contest
Test instructions: Solves the problem idea of floor (n/i) in the [L,r] interval for a given number N: the direct violence loop sums it up

 #include <queue> #include <cmath> #include <cstdio> #include <string> #

Include <cstring> #include <iostream> #include <algorithm> using namespace std; #pragma COMMENT (linker, "/stack:1024000000,1024000000") #define FIN freopen ("Input.txt", "R", stdin) #define FOUT freopen ("Output.txt", "w", stdout) #define FST First #define SND second typedef __i
Nt64 LL;

typedef pair<int, int> PII;

Const double EPS = 1e-10;
const int MAXN = 1e7 + 5;

const int INF = 0X3F3F3F3F;

int T, N, M;
    int main () {#ifndef Online_judge FIN;
FOUT;
    #endif//Online_judge int cas = 0, res;
    int L, R;
    scanf ("%d", &t);
        while (T--) {res = 0;
        scanf ("%d%d%d", &n, &l, &r);
        for (int i = L; I <= R; i++) {res + = n/i;
    } printf ("%d\n", res);
} return 0; }
f.problem 2107 Hua Rong Dao accept:372 submit:806
Time limit:1000 mSec Memory limit:32768 KB
problem Description

Cao Cao was hunted under thousands of enemy soldiers when he escaped from Hua Rong Dao. Assuming Hua Rong Dao is a narrow aisle (one n*4 rectangle), while the Cao Cao can be regarded as one 2*2 grid. Cross General can be regarded as one 1*2 grid. Vertical General can regarded as one 2*1 grid. Soldiers can regarded as one 1*1 grid. Now Hua Rong Dao are full of people and no grid is empty.

There is the only one Cao Cao. The number of cross general, vertical general, and soldier are not fixed. How many ways can all the people stand? Input

There is a single integer t (t≤4) on the first line of the test data indicating, that there is t test cases.

Then for each case, only one integer-N (1≤n≤4) in a-line indicates the length of Hua Rong Dao. Output For each test case, print the number of ways all the people can stand in a single line. sample Input 212 sample Output 018 Hint

Here is 2 possible ways for the Hua Rong Dao 2*4. Source "Higher Education Society Cup" the third Fujian Province University student Program design Competition
Test instructions: give you a N * 4 (1 <= n <= 4) of the rectangle, let you cover with four different rectangles, the rectangles are 1*1,2*1,2*1,2*2, where the 2*2 rectangle has only one piece, and the other three kinds of rectangles have no limit, the final must cover all the places n*4, Then solve how many kinds of coverage methods
Problem-Solving ideas: Direct DFS constantly using four methods to cover the solution can be

#include <queue> #include <cmath> #include <cstdio> #include <string> #include <cstring> #

Include <iostream> #include <algorithm> using namespace std; #pragma COMMENT (linker, "/stack:1024000000,1024000000") #define FIN freopen ("Input.txt", "R", stdin) #define FOUT freopen ("Output.txt", "w", stdout) #define FST First #define SND second typedef __i
Nt64 LL;

typedef pair<int, int> PII;

Const double EPS = 1e-10;
const int MAXN = 1e7 + 5;

const int INF = 0X3F3F3F3F;
int T, N, M;
LL ans = 0;
BOOL CC, VIS[5][5];
		void Dfs (int x, int y) {if (x = = N) {if (!CC) ans++;
	Return
	} int xx = x, yy = y + 1;
		if (yy > 3) {xx++;
	yy = 0;
	} if (Vis[x][y]) {dfs (xx, yy);
				} else {for (int i = 0; i < 4; i++) {if (i = = 0) {//2 * 2 if (!CC) continue; else {if (x + 1 < N && y + 1 < 4 &&!vis[x + 1][y] &&!vis[x][y + 1] &&!vis[x + 1][y + 1]) {cc = FALSE;
						Vis[x][y] = vis[x + 1][y] = vis[x][y + 1] = vis[x + 1][y + 1] = true;
						DFS (xx, yy);
						CC = TRUE;
					Vis[x][y] = vis[x + 1][y] = vis[x][y + 1] = vis[x + 1][y + 1] = false; }}} else if (i = = 1) {//2 * 1 if (x + 1 < N &&!vis[x + 1][y]) {Vis[x][y] = vis[x + 1][y]
					= true;
					DFS (xx, yy);
				Vis[x][y] = vis[x + 1][y] = false; }} else if (i = = 2) {//1 * 2 if (y + 1 < 4 &&!vis[x][y + 1]) {Vis[x][y] = vis[x][y + 1] = True
					;
					DFS (xx, yy);
				Vis[x][y] = vis[x][y + 1] = false;
				}} else if (i = = 3) {//1 * 1 vis[x][y] = true;
				DFS (xx, yy);
			Vis[x][y] = false;
	}}}} int main () {#ifndef Online_judge FIN;
FOUT;
	#endif//Online_judge int cas = 0, res, ans[5] = {0, 0, 18, 284, 4862};
	scanf ("%d", &t);
		while (t--) {scanf ("%d", &n);
	printf ("%d\n", Ans[n]);
} return 0; }<span style= "FONT-SIZE:12PX;" > </spAn> 
g.problem 2108 Mod problem accept:104 submit:432
Time limit:1000 mSec Memory limit:32768 KB
problem Description

Given one non-negative integer A and one positive integer b, it's very easy for us to calculate A Mod B. Here's a Mod B means the remainder of the answer after A was divided by B. For example, 7 mod 5 = 2, mod 3 = 0, 0 mod 3 = 0.

In this problem, we use the following rules to express A.

(1) One non-empty string that was contains {0,1,2,3,4,5,6,7,8,9} is valid.

For example, 123, 000213, 99213. (Leading zeros is OK on this problem)

(2) If W is valid and then [w]x if valid. Here's x is one integer that 0<x<10.

For example, [012]2=012012, [35]3[7]1=3535357.

(3) If W and V are valid, then WV is valid.

For example, W=[231]2 and V=1, then wv=[231]21 was valid (which is 2312311).

Now is given A and B. Here A was express as the rules above and B is simply one integer, you were expected to output the A Mod B. Input

The first line of the input contains an integer T (t≤10), indicating the number of the test cases.

Then T-cases, for any case, only lines.

The first line was one non-empty and valid string that expresses A, the length of the string was no more than 1,000.

The second line is one integer B (0<b<2,000,000,000).

May assume, the length of number A in decimal notation would less than 2^63.  output For each test case, output A Mod B in A single line.  sample Input 3
[0]9[[1]2]3
10007
[[213231414343214231]5]1
10007
[0012]1 1
 sample Output 1034
3943
0
 source "Higher Education Society Cup" the third Fujian University student program establishment Count Contest
Test instructions: give you a string A and a number B, where the string contains the number 0-9 and ' [' and '] ', the string is handled as follows: [123]2=123123 [123]21=1231231] finally let you solve the string of the final form of the number of the B modulo Problem solving idea: can be solved by the idea of ret = (ret *% b + a[i]-' 0 ')% B, then the number one by one in [] will be calculated by recursive thinking

/* Header File Template */#include <map> #include <set> #include <cmath> #include <ctime> #include <queue> #include <stack> #include <vector> #include <cctype> #include <cstdio> #include <string> # Include <cstring> #include <sstream> #include <cstdlib> #include <iomanip> #include <

typeinfo> #include <iostream> #include <algorithm> #include <functional> using namespace std; #define PB push_back #define MP Make_pair #define MEM (A, X) memset (A, X, sizeof (a)) #define copy (A, b) memcpy (A, B, sizeof (a)) #define Lson RT << 1, L, MID #define Rson RT << 1|1, Mid + 1, r #define FIN freopen ("Input.txt", "R", STD
IN) #define FOUT freopen ("Output.txt", "w", stdout) typedef long long LL;
typedef pair<int, int > PII;
typedef pair<int, string> PIS;
typedef PAIR&LT;LL, int>pli;
typedef PAIR&LT;LL, ll>pll;

typedef unsigned long long ULL; Template<typename t> void Print (t*P, t* q, String Gap = "", bool flag = false) {int d = p < Q?
	1:-1;
		while (P! = q) {if (flag) cout << gap[0] << *p << gap[1];
		else cout << *p;
		p + = D;
	if (P! = q &&!flag) cout << Gap;
} cout << Endl;
	} template<typename t> void print (const T &a, String bes = "") {int len = bes.length ();
	if (Len >= 2) cout << bes[0] << a << bes[1] << Endl;
else cout << a << Endl;  } template<typename t> void Debug (t* p, t* q, String Gap = "", bool flag = False) {#ifndef Online_judge int d = P < Q?
	1:-1;
	cout << "Debug out:";
		while (P! = q) {if (flag) cout << gap[0] << *p << gap[1];
		else cout << *p;
		p + = D;
	if (P! = q &&!flag) cout << Gap;
} cout << Endl; #endif} template<typename t> void debug (const T &a, String bes = "") {#ifndef Online_judge int len = Bes.le
	Ngth (); cout << "Debug oUT: ";
	if (Len >= 2) cout << bes[0] << a << bes[1] << Endl;
else cout << a << Endl;

#endif} void Io_init () {Ios::sync_with_stdio (false);}

ll Llabs (const LL a) {return a >= 0? A:-A;}
Const double PI = 3.1415926535898;
Const double EPS = 1e-10;
const int MAXM = 1e5 + 5;
const int MAXN = 1E3 + 5;

const int INF = 0X3F3F3F3F;
/* Header file template */int T, Slen;
Char A[MAXN];
LL b;

stack<char>c;
	ll Mod_pow (ll x, int p, ll MoD) {ll ret = 1;
		while (P > 0) {if (P & 1) ret = ret * x% MoD;
		x = x * x% MoD;
	P >>= 1;
} return ret;
	} PLI solve (int &l) {int cnt = 0,len = 0;
	LL ans = 0;
			while (L < Slen) {if (a[l] = = ' [') {int r = + + L;
			PLI a = Solve (r);
			int k = a[r + 1]-' 0 ';
			for (int i = 0; i < K; i + +) {ans = (ans * MOD_POW (ten, A.second, b)% B + a.first)% B;
			} len + k * A.second;
		L = R + 2;
		} else if (a[l] = = '] ') {break; } else {ans = (ans *% b + a[l + +]-' 0 ')% B;
		Len + +;
}} return PLI (ans, Len);
	} int main () {#ifndef Online_judge//fin;
FOUT;
	#endif io_init ();
	scanf ("%d", &t);
		while (T--) {scanf ("%s%i64d", A, &b);
		Slen = strlen (A);
		int k = 0;
	printf ("%i64d\n", solve (k). First);
} return 0;
 }
H.problem 2109 Mountain number accept:228 submit:571
Time limit:1000 mSec Memory limit:32768 KB
problem Description

One integer number x is called "Mountain number" if:

(1) x>0 and x is an integer;

(2) Assume x=a[0]a[1]...a[len-2]a[len-1] (0≤a[i]≤9, a[0] is positive). Any a[2i+1] was larger or equal to a[2i] and a[2i+2] (if exists).

For example, 111, 893, 7 is "Mountain number" while 123, and 76889 is not "Mountain number".

Now is given L and R, how many "Mountain number" can be found between L and R (inclusive)? Input

The first line of the input contains an integer T (t≤100), indicating the number of the test cases.

Then T cases, the for any case, is only integers L and R (1≤l≤r≤1,000,000,000).  output For each test case, output the number of "Mountain number" between L and R.  sample Input 101 1001 +  sample Output 954384  source "Higher Education Society Cup" the third Fujian University student Program Design Competition
Test instructions: give you an interval [l,r] to solve the number of odd digits greater than the number of adjacent even digits in this interval. Problem-solving ideas: A typical digital DP, basically a road naked problem, directly from the high processing, and then used in the search for the next bit, with a variable tag when the

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.