Saratov State University :: Online Contester


::Go
- home
- news
- register
- update personal info
- problemset archive
- submit
- status online
- standing
- contests
- virtual contests
- forum
- statistic
- FAQ
- links
- projects

::Poll
Are you registered on Codeforces?
Yes
No
What is it???

[results]

::webboard

Wrong Answer on TestCase 2
Author: experience257
ID: 053648
Problem: H
Contest: 38
Date: 2012-08-14 14:34:18

please tell me test case 2 on which i am getting wrong answer or point out bug in my code
my code :

#include <iostream>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define ll long long
#define pb push_back

vector <char> vc;
vector <ll> vl;
int p = 0;
ll gcd1;

ll gcd( ll a, ll b )
{
if ( a == 0LL ) return b;
else return gcd( b%a, a );
}

void gen( int s, string str, int k )
{
map<char,int> m;
int x = 9;
int cnt = 0;

int myint[k];
while ( s != 0 ) {
if ( s & 1 ) {
myint[k-1-cnt] = x;
cnt++;
}
x--;
s = s / 2;
}

int oo = 0;
do {
if ( oo > 100 ) break;
cnt = 0;
for ( int i = 0; i < vc.size(); i++ ) {
m[vc[i]] = myint[i];
}
ll num = 0;
ll ten = 1;
for ( int i = str.size()-1; i >= 0; i-- ) {
num += ten*m[str[i]];
ten = ten*10;
}
if ( m[str[0]] != 0 ) {
p++;
oo++;
vl.pb( num );
}
}
while( next_permutation (myint ,myint + k) );
m.clear();
}

ll build( int N, int k, string str )
{
int s = (1 << k) - 1;

ll num;
int cnt = 0;
while (!(s & 1 << N) && p < 2000 )
{
gen( s, str, k );
int lo = s & ~(s - 1);
int lz = (s + lo) & ~s;
s |= lz;
s &= ~(lz - 1);
s |= (lz / lo / 2) - 1;

}
}

vector<ll> fac( ll N )
{
vector<ll> ans;
ll k = N;

for ( ll i = 1; i*i <= N; i++ ) {
if ( N%i == 0 ) {
ans.pb( i );
if ( i*i != N ) ans.pb( N/i );
}
}
sort( ans.begin(), ans.end() );

return ans;
}

int main()
{
int n;
scanf( "%d", &n );

string s;
int diff;

int vis[26];
for ( int i = 1; i <= n; i++ ) {
cin >> s;
diff = 0;
memset( vis, 0, sizeof vis );
for ( int j = 0; j < s.size(); j++ ) {
if ( vis[s[j]-'a'] == 0 ) {
diff++;
vis[s[j]-'a'] = 1;
vc.pb( s[j] );
}
}


if ( diff == 10 ) {
if ( s.size() == 10 ) gcd1 = 9;
else {
int y = 0;
for ( int j = 0; j < s.size(); j++ ) {
vis[s[j]-'a']++;
if ( vis[s[j]-'a'] == 5 ) {
y = s[j]-'a';
}
}
if ( vis[y] == 5 ) gcd1 = 3;
else gcd1 = 1;
}
}
else if( diff == s.size() ) gcd1 = 1;
else {
build( 10, diff, s );
gcd1 = vl[0];
for ( int j = 1; j < vl.size(); j++ ) {
gcd1 = gcd( gcd1, vl[j] ) ;
if ( gcd1 == 1 ) break;
}
}

vector<ll> fc = fac( gcd1 );

printf( "Case %d:", i );
for ( int j = 0; j < fc.size(); j++ ) {
printf( " %lld", fc[j] );
}
cout << endl;

vc.clear();
vl.clear();
p = 0;
}

return 0;
}


see sub-tree reply to that message


::Login
Forgot password?

::News
22.10.12 - The problems from the Southern Subregional Programming Contest 2012 added to the problemset archive (542 - 553).
22.10.12 - After the start of the contest the statements in PDF will be available by the link.
23.10.11 - The problems from the Southern Subregional Programming Contest 2011 added to the problemset archive (530 - 541).

::Counter

Server time: 2017-11-22 04:37:01Online Contester Team © 2002 - 2016. All rights reserved.