Topic Connection: Click to open link
Problem Solving Ideas:
Simple violence
Full code:
#include < iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <set>using namespace Std;int n;int a[300]; BOOL Check (int key) {set<int> s; S.clear (); for (int i = 1; i < key; I + +) {if (key% i = = 0) S.insert (i); } Set<int>::iterator it; int sum = 0; for (it = S.begin (); It! = S.end (); it++) {sum + = *it; } if (sum = = key) return true; else return false;} int main () {#ifdef Doubleq freopen ("In.txt", "R", stdin); #endif//Doubleq while (CIN >> n) {int a[1001]; int cnt = 0; for (int i = 1; I <= n; i + +) {if (check (i)) {a[cnt++] = i; }} for (int i = 0; i < cnt; i + +) printf ("%d%s", a[i], i = = cnt-1? "\ n": ""); }}
Topic Connection: Click to open link
Problem Solving Ideas:
Java Dafa Good
Full code:
Import Java.math.biginteger;import Java.io.*;import Java.util.scanner;public class Main {public static void main ( String[] Argvs) { Scanner cin = new Scanner (system.in); String A; int n; while (Cin.hasnext ()) { a = Cin.next (); n = cin.nextint (); BigInteger sum = new BigInteger ("0"); for (int i = 1; I <= n; i + +) { String temp = ""; for (int j = 1; J <= I; j + +) { temp + = A; } BigInteger k = new BigInteger (temp); sum = Sum.add (k); } SYSTEM.OUT.PRINTLN (sum); } }
Topic Connection: Click to open link
Problem Solving Ideas:
Sort
Full code:
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring>using namespace Std;int n;int A[300];int Main () { #ifdef doubleq freopen ("In.txt", "R", stdin); #endif//Doubleq while (CIN >> N) {for (int i = 0; i < n; i + +) cin >> A[i]; int x; CIN >> X; int flag = 0; for (int i = 0; i < n; i + +) { if (a[i] = = x) { cout << i << Endl; flag = 1; break; } } if (!flag) cout << "1" << Endl; }}
Topic Connection: Click to open link
Problem Solving Ideas:
Violence
Full code:
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <set >using namespace Std;const int INF = 1000000000;int n;int a[30];int main () { #ifdef doubleq freopen ("In.txt", " R ", stdin); #endif//Doubleq while (CIN >> N) { int maxx =-inf, Minn = INF, Maxpos, Minpos; for (int i = 0; i < n; i + +) { cin >> a[i]; if (A[i] > Maxx) { Maxx = a[i]; Maxpos = i; } if (A[i] < Minn) { minn = a[i]; Minpos = i; } } Swap (A[maxpos], A[minpos]); for (int i = 0; i < n; i + +) printf ("%d%s", a[i], i = = n-1? "\ n": "");} }
Topic Connection: Click to open link
Problem Solving Ideas:
Sort
Full code:
#include <functional> #include <algorithm> #include <iostream> #include <fstream> #include < sstream> #include <iomanip> #include <numeric> #include <cstring> #include <climits># Include <cassert> #include <complex> #include <cstdio> #include <string> #include <vector > #include <bitset> #include <queue> #include <stack> #include <cmath> #include <ctime> #include <list> #include <set> #include <map>using namespace std; #pragma COMMENT (linker, "/stack:102400000,102400000") typedef long long ll;typedef double db;typedef unsigned uint; typedef unsigned long long ULL; /** Constant List. **///{const int MOD = INT (1e9) +7;const int INF = 0x3f3f3f3f;const LL inff = 0x3f3f3f3f3f3f3f3fll;const DB EPS = 1e-9;con St db OO = 1e20;const db PI = ACOs (-1.0); M_PI; BOOL CMP (char A, char b) {return a < b;} Char A[1000001];int main () {#ifdef Doubleq freopen ("In.txt", "R", stdin);#endif string S; while (Cin >> s) {int len = s.length (); for (int i = 0; i < len; i + +) a[i] = s[i]; A[len] = ' + '; Sort (A, a + len, CMP); for (int i = 0; i < len; i + +) cout << a[i]; cout << Endl; }}
2010 The computer Research of Harbin Institute of Technology The real problem