for (i = 0; i < 256; i++) t[i] = 0; for (i = 0; i < s.length(); i++) t[s[i]]++; for (i = 0; i < s.length(); i++) if (t[s[i]] == 1) { cout << s[i] << endl; return 0; }
cout << \}
ÊäÈ룺xyzxyw Êä³ö£º_________
2.#include using namespace std; int g(int m, int n, int x) { int ans = 0; int i;
if (n == 1) return 1;
for (i = x; i <= m / n; i++) ans += g(m - i, n - 1, i); return ans; } int main() { int t, m, n; cin >> m >> n;
cout << g(m, n, 0) << endl; return 0; }
ÊäÈ룺7 3 Êä³ö£º_________
3.#include using namespace std; int main() { string ch; int a[200]; int b[200]; int n, i, t, res; cin >> ch; n = ch.length();
for (i = 0; i < 200; i++) b[i] = 0;
for (i = 1; i <= n; i++) { a[i] = ch[i - 1] - '0'; b[i] = b[i - 1] + a[i]; }
res = b[n]; t = 0;
for (i = n; i > 0; i--) { if (a[i] == 0) t++;
if (b[i - 1] + t < res) res = b[i - 1] + t; }
cout << res << endl; return 0; } ÊäÈ룺
Êä³ö£º_________
4.#include using namespace std;
int main() { int n, m; cin >> n >> m; int x = 1;
int y = 1; int dx = 1; int dy = 1; int cnt = 0; while (cnt != 2) { cnt = 0; x= x + dx; y= y + dy;
if (x == 1 || x == n) { ++cnt; dx = -dx; }
if (y == 1 || y == m) { ++cnt; dy = -dy; } }
cout << x << \}
ÊäÈë 1£º4 3
Êä³ö 1£º_________£¨3 ·Ö£© ÊäÈë 2£º2017 1014
Êä³ö 2£º_________£¨5 ·Ö£©
ËÄ¡¢ÍêÉÆ³ÌÐò£¨¹² 2 Ì⣬ÿÌâ 14 ·Ö£¬¹²¼Æ 28 ·Ö£©
1.£¨¿ìËÙÃÝ£©ÇëÍêÉÆÏÂÃæµÄ³ÌÐò£¬¸Ã³ÌÐòʹÓ÷ÖÖη¨Çóxp?mod m µÄÖµ¡££¨µÚÒ»¿Õ 2 ·Ö£¬ÆäÓà 3 ·Ö£©
ÊäÈ룺Èý¸ö²»³¬¹ý 10000 µÄÕýÕûÊý x£¬p£¬m¡£ Êä³ö£ºxp?mod m µÄÖµ¡£
Ìáʾ£ºÈô p ΪżÊý£¬xp=(x2)p/2£»Èô p ÎªÆæÊý£¬xp=x*(x2)(p-1)/2¡£ #include using namespace std; int x, p, m, i, result; int main() { cin >> x >> p >> m;
result =?? ? ? ? ?(1) ? ? ? ??; while (?? ? ? ? ?(2) ? ? ? ??) { if (p % 2 == 1)
result =?? ? ? ? ?(3) ? ? ? ??; p /= 2;
x =?? ? ? ? ?(4) ? ? ? ??; }
cout <? ? ? ? ?(5) ? ? ? ??<< endl;