C++ Argument Error
I have a function in which
bool(*p)(const vector<int>&, int)
is one of the arguments. I know it's being used to call one of two other
functions, but I can't seem to figure out how to actually call it (getting
a no matching function for call error). I currently have
myFunct(i, j, myFunct2(i, 0);
Any help is appreciated.
Wednesday, 11 September 2013
Unusual traffic from your computer network - Google Maps v3 API
Unusual traffic from your computer network - Google Maps v3 API
So my site has been loading well with no problem for several months and
today, I am getting a "Unusual traffic from your computer network"
notification. My site is just trying to display maps - What could be going
on?
the website is Onlinecustommaps.com
I am very confused and would love to resolve this problem.
thanks
So my site has been loading well with no problem for several months and
today, I am getting a "Unusual traffic from your computer network"
notification. My site is just trying to display maps - What could be going
on?
the website is Onlinecustommaps.com
I am very confused and would love to resolve this problem.
thanks
Looking for a better formula to rank user activity in SQL
Looking for a better formula to rank user activity in SQL
I need to create a table with every single date from 2011 - today and with
every single user login_id and then the user's last activity prior to
"the_date".. i.e. if this person's last activity was on 1/2/13
the_date | login_id | days_since_last_activity
1/2/13 1 0
1/3/13 2 1
1/4/14 3 2
I'm currently using a ROW_NUMBER formula to rank all of the user's
activity based on the date and then pulls RANK = 1 for each the_date and
does a DATEDIFF calculation for column 3... each time and it's making
things very inefficient (as you can imagine).
Is there any other formula that may serve the same purpose?
I need to create a table with every single date from 2011 - today and with
every single user login_id and then the user's last activity prior to
"the_date".. i.e. if this person's last activity was on 1/2/13
the_date | login_id | days_since_last_activity
1/2/13 1 0
1/3/13 2 1
1/4/14 3 2
I'm currently using a ROW_NUMBER formula to rank all of the user's
activity based on the date and then pulls RANK = 1 for each the_date and
does a DATEDIFF calculation for column 3... each time and it's making
things very inefficient (as you can imagine).
Is there any other formula that may serve the same purpose?
ScriptEngineManager().getEngineByName("jruby") returns NULL
ScriptEngineManager().getEngineByName("jruby") returns NULL
I am trying to use JRuby in Java and I keep getting a null returned when I
do:
ScriptEngine blah = new ScriptEngineManager().getEngineByName("jruby")
returns NULL
I've looked at any material I can find but nothing seems to get me any
further then I have so far. Plus alot of the materials are 5+ years old.
I'm sure the classpaths are correct and I've done the setup correct.
Please help.
I am trying to use JRuby in Java and I keep getting a null returned when I
do:
ScriptEngine blah = new ScriptEngineManager().getEngineByName("jruby")
returns NULL
I've looked at any material I can find but nothing seems to get me any
further then I have so far. Plus alot of the materials are 5+ years old.
I'm sure the classpaths are correct and I've done the setup correct.
Please help.
Python - print traceback and stop execution on worker exception
Python - print traceback and stop execution on worker exception
In my application, I'm using several worker threads and a mainloop which
is a part of external module and can't be modified. When a worker thread
raises an exception, the app should stop the mainloop, do some cleanup,
print the worker exception traceback and exit. The mainloop should be
stopped by raising ExitMainLoop exception.
Here's an example code:
from time import sleep
from threading import Thread
class MyException(BaseException):
pass
class ExitMainLoop(BaseException):
pass
def main_loop():
print('started main loop')
try:
while True:
print('.')
sleep(1)
except ExitMainLoop:
pass
def do_work():
print('started worker thread')
sleep(5)
raise MyException
def main():
worker = Thread(target=do_work)
worker.daemon = True
worker.start()
main_loop()
if __name__ == '__main__':
main()
In my application, I'm using several worker threads and a mainloop which
is a part of external module and can't be modified. When a worker thread
raises an exception, the app should stop the mainloop, do some cleanup,
print the worker exception traceback and exit. The mainloop should be
stopped by raising ExitMainLoop exception.
Here's an example code:
from time import sleep
from threading import Thread
class MyException(BaseException):
pass
class ExitMainLoop(BaseException):
pass
def main_loop():
print('started main loop')
try:
while True:
print('.')
sleep(1)
except ExitMainLoop:
pass
def do_work():
print('started worker thread')
sleep(5)
raise MyException
def main():
worker = Thread(target=do_work)
worker.daemon = True
worker.start()
main_loop()
if __name__ == '__main__':
main()
Regex for advanced substitution
Regex for advanced substitution
I need to regexp for validating text like that:
Matches:
FIELD(val1,val2>res1&val2>res2)
f(val1>12)
FIELD(12>res1&val2>res2)
Not matches:
(val1,val2>res1&val2>res2)
FIELD(,val2>res1&val2>res2)
FIELD(val1,val2>)
Please help. I am really bad in reg. expressions
I need to regexp for validating text like that:
Matches:
FIELD(val1,val2>res1&val2>res2)
f(val1>12)
FIELD(12>res1&val2>res2)
Not matches:
(val1,val2>res1&val2>res2)
FIELD(,val2>res1&val2>res2)
FIELD(val1,val2>)
Please help. I am really bad in reg. expressions
What is wrong with my code ? Kindly help me
What is wrong with my code ? Kindly help me
The Question
Given an integer N. Integers A and B are chosen randomly in the range
[1..N]. Calculate the probability that the Greatest Common Divisor(GCD) of
A and B equals to B. Input
The first line of the input contains an integer T denoting the number of
test cases. The description of T test cases follows. Each test case
consists of a single integer N on a separate line. Output
For each test case, output a single line containing probability as an
irreducible fraction. Example
Input: 3 1 2 3
Output: 1/1 3/4 5/9 Constraints
1<=T<=103
1<=N<=109
My code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 40960
long int favCases( long int N )
{
int i;
long int favNumberOfCases=N,sum=0;
if( N<10000 )
{
for ( i = 2; i <= N; i++ )
{
favNumberOfCases = favNumberOfCases + N/i;
}
return favNumberOfCases;
}
else
{
for ( i = 2; i <= N / 10000; i++ )
{
favNumberOfCases = favNumberOfCases + N/i;
}
for ( i = 1; i <= 9999; i++ )
{
sum = sum + ( N / i - N / ( i + 1 ) ) * i;
}
return favNumberOfCases+sum;
}
}
long int gcd(long int a, long int b)
{
long int r;
while( b != 0 )
{
r = a % b;
a = b;
b = r;
}
return a;
}
int main( int argc, char *argv[] )
{
char buffer[SIZE];
int i = 0, c, count = 0;
long int N = 0;
int T;
long int favCases( long int N );
scanf( "%d", &T );
scanf( "%ld", &N );
while ( ( c = fread( buffer, sizeof (char), SIZE, stdin ) ) > 0 )
{
for ( i = 0; i < c; i++ )
{
if ( buffer[i] == '\n' )
{
if( count == T ) break;
printf( "%ld/%ld\n",
( favCases(N) / gcd( favCases(N), N * N ) ),
( N * N ) / gcd( favCases(N), N * N )
);
N = 0;
count++;
}
else
{
N = ( N * 10 ) + ( buffer[i] - '0' );
}
}
if( count == T ) break;
}
return (0);
}
The code is giving correct outputs and is compiling quite quickly but
still codechef is saying that my answer is wrong ? I have being trying to
figure out the error but can't find one. I have checked for corner cases
etc. Kindly help me.
The Question
Given an integer N. Integers A and B are chosen randomly in the range
[1..N]. Calculate the probability that the Greatest Common Divisor(GCD) of
A and B equals to B. Input
The first line of the input contains an integer T denoting the number of
test cases. The description of T test cases follows. Each test case
consists of a single integer N on a separate line. Output
For each test case, output a single line containing probability as an
irreducible fraction. Example
Input: 3 1 2 3
Output: 1/1 3/4 5/9 Constraints
1<=T<=103
1<=N<=109
My code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 40960
long int favCases( long int N )
{
int i;
long int favNumberOfCases=N,sum=0;
if( N<10000 )
{
for ( i = 2; i <= N; i++ )
{
favNumberOfCases = favNumberOfCases + N/i;
}
return favNumberOfCases;
}
else
{
for ( i = 2; i <= N / 10000; i++ )
{
favNumberOfCases = favNumberOfCases + N/i;
}
for ( i = 1; i <= 9999; i++ )
{
sum = sum + ( N / i - N / ( i + 1 ) ) * i;
}
return favNumberOfCases+sum;
}
}
long int gcd(long int a, long int b)
{
long int r;
while( b != 0 )
{
r = a % b;
a = b;
b = r;
}
return a;
}
int main( int argc, char *argv[] )
{
char buffer[SIZE];
int i = 0, c, count = 0;
long int N = 0;
int T;
long int favCases( long int N );
scanf( "%d", &T );
scanf( "%ld", &N );
while ( ( c = fread( buffer, sizeof (char), SIZE, stdin ) ) > 0 )
{
for ( i = 0; i < c; i++ )
{
if ( buffer[i] == '\n' )
{
if( count == T ) break;
printf( "%ld/%ld\n",
( favCases(N) / gcd( favCases(N), N * N ) ),
( N * N ) / gcd( favCases(N), N * N )
);
N = 0;
count++;
}
else
{
N = ( N * 10 ) + ( buffer[i] - '0' );
}
}
if( count == T ) break;
}
return (0);
}
The code is giving correct outputs and is compiling quite quickly but
still codechef is saying that my answer is wrong ? I have being trying to
figure out the error but can't find one. I have checked for corner cases
etc. Kindly help me.
Subscribe to:
Posts (Atom)