Example #1
0
int main() {
	freopen("in.txt", "r", stdin);
	scanf("%d%d%d", &a, &x, &y);
	if (y % a == 0) {
		no();
		return 0;
	}
	else {
		int l = y / a;
		if (l == 0) {
			if (2 * x == a || 2 * x > a || 2 * x == -a || 2 * x < -a) {
				no();
				return 0;
			}
			else {
				printf("1\n");
				return 0;
			}
		}
		else if (l % 2 == 1) {
			if (2 * x == a || 2 * x > a || 2 * x == -a || 2 * x < -a) {
				no();
				return 0;
			}
			else {
				int ret = (3 * l + 1) / 2;
				printf("%d\n", ret);
				return 0;
			}
		}
		else {	   
			if (x == a || x > a || x == -a || x < -a || x == 0) {
				no();
				return 0;
			}
			else if (x < 0) {
				l--;
				int ret = (3 * l + 1) / 2 + 1;
				printf("%d\n", ret);
				return 0;
			}
			else {
				l--;
				int ret = (3 * l + 1) / 2 + 2;
				printf("%d\n", ret);
				return 0;
			}
		}
	} 
}
Example #2
0
void Page::draw(QPainter* painter) const
      {
      if (score()->layoutMode() != LayoutMode::PAGE)
            return;
      //
      // draw header/footer
      //

      int n = no() + 1 + score()->pageNumberOffset();
      painter->setPen(curColor());

      QString s1, s2, s3;

      if (score()->styleB(Sid::showHeader) && (no() || score()->styleB(Sid::headerFirstPage))) {
            bool odd = (n & 1) || !score()->styleB(Sid::headerOddEven);
            if (odd) {
                  s1 = score()->styleSt(Sid::oddHeaderL);
                  s2 = score()->styleSt(Sid::oddHeaderC);
                  s3 = score()->styleSt(Sid::oddHeaderR);
                  }
            else {
                  s1 = score()->styleSt(Sid::evenHeaderL);
                  s2 = score()->styleSt(Sid::evenHeaderC);
                  s3 = score()->styleSt(Sid::evenHeaderR);
                  }

            drawHeaderFooter(painter, 0, s1);
            drawHeaderFooter(painter, 1, s2);
            drawHeaderFooter(painter, 2, s3);
            }

      if (score()->styleB(Sid::showFooter) && (no() || score()->styleB(Sid::footerFirstPage))) {
            bool odd = (n & 1) || !score()->styleB(Sid::footerOddEven);
            if (odd) {
                  s1 = score()->styleSt(Sid::oddFooterL);
                  s2 = score()->styleSt(Sid::oddFooterC);
                  s3 = score()->styleSt(Sid::oddFooterR);
                  }
            else {
                  s1 = score()->styleSt(Sid::evenFooterL);
                  s2 = score()->styleSt(Sid::evenFooterC);
                  s3 = score()->styleSt(Sid::evenFooterR);
                  }

            drawHeaderFooter(painter, 3, s1);
            drawHeaderFooter(painter, 4, s2);
            drawHeaderFooter(painter, 5, s3);
            }
      }
void QQuickDialog::click(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role)
{
    setVisible(false);
    m_clickedButton = static_cast<StandardButton>(button);
    emit buttonClicked();
    switch (role) {
    case QPlatformDialogHelper::AcceptRole:
        emit accept();
        break;
    case QPlatformDialogHelper::RejectRole:
        emit reject();
        break;
    case QPlatformDialogHelper::DestructiveRole:
        emit discard();
        break;
    case QPlatformDialogHelper::HelpRole:
        emit help();
        break;
    case QPlatformDialogHelper::YesRole:
        emit yes();
        break;
    case QPlatformDialogHelper::NoRole:
        emit no();
        break;
    case QPlatformDialogHelper::ApplyRole:
        emit apply();
        break;
    case QPlatformDialogHelper::ResetRole:
        emit reset();
        break;
    default:
        qWarning("unhandled Dialog button %d with role %d", (int)button, (int)role);
    }
}
Example #4
0
void solve(int n,int K){
    if(n<=2){
        yes();
        return;
    }
    int mf[12];
    for(int i=0;i<12;i++){
        mf[i]=0;
    }
    for(int i=0;i<n;i++){
        mf[x[i]%(K+1)]++;
    }
    int c=0;
    int f[12];
    for(int i=0;i<12;i++){
        if(mf[i]>0){
            f[c++]=i;
        }
    }
    if(c==1){
        yes();
        return;
    }
    if(c==2){
        
        if(mf[f[0]]==1||mf[f[1]]==1){
            yes();
            return;
        }
    }
    no();
}
bool ManageSieveCommand::getScript()
{
    if ( !d->query ) {
        EString name = string();
        end();
        d->query =
            new Query( "select script from scripts where owner=$1 and name=$2",
                       this );
        d->query->bind( 1, d->sieve->user()->id() );
        d->query->bind( 2, name );
        if ( d->no.isEmpty() )
            d->query->execute();
    }

    if ( !d->query->done() )
        return false;

    Row * r = d->query->nextRow();

    if ( !r )
        no( "No such script" );
    else if ( !d->query->failed() )
        d->sieve->enqueue( encoded( r->getEString( "script" ) ) + "\r\n" );

    return true;
}
Example #6
0
//检查是否员工编号是否已存在
bool Utils::CheckNo(MYSQL mysql,SQLUtils* sqlutils,CString staff_no)
{
	MYSQL_RES *result = NULL;
	mysql_init(&mysql);
	string serverName = sqlutils->getServerName();
	string userName = sqlutils->getUserName();
	string password = sqlutils->getPassword();
	string databaseName = sqlutils->getDatabaseName();
	int port = sqlutils->getPort();
	if (mysql_real_connect(&mysql,serverName.c_str(),userName.c_str(),password.c_str(),databaseName.c_str(),port,NULL,0))
	{
		string no(staff_no.GetBuffer(staff_no.GetLength()));
		string sql = "select staff_no from t_staff where staff_no=";
		sql.append(1,'\'').append(no).append(1,'\'');
		mysql_query(&mysql,sql.c_str());
		result = mysql_store_result(&mysql);
		int rowcount = mysql_num_rows(result);
		if (rowcount > 0)
		{
			return true;
		}

	}else{
		AfxMessageBox("系统出错");
	}
	return false;
}
void CContextbookContainer::sms_current()
{
	CALLSTACKITEM(_L("CContextbookContainer::sms_current"));

	TPtrC no( book->get_phone_no(get_current_idx()) );

	if (no!=KNullDesC) {
		if (iLog) {
			iLog->write_time();
			iLog->write_to_output(_L("Smsing: "));
			iLog->write_to_output(listbox->Model()->ItemTextArray()->MdcaPoint(get_current_idx()));
			iLog->write_nl();
		}
		CParaFormatLayer* paraf=CParaFormatLayer::NewL();
		CleanupStack::PushL(paraf);

		CCharFormatLayer* charf=CCharFormatLayer::NewL();
		CleanupStack::PushL(charf);

		CRichText* body;
		body=CRichText::NewL(paraf, charf);
		CleanupStack::PushL(body);
		
		CDesCArrayFlat* a=new CDesCArrayFlat(1);
		CleanupStack::PushL(a);
		a->AppendL(no);
		//s->CreateAndSendMessageL(KSenduiMtmSmsUid, 0, 0, KNullUid, a, 0, EFalse);
		sendui->CreateAndSendMessageL(KUidMsgTypeSMS, body, 0, KNullUid, a);
		CleanupStack::PopAndDestroy(4); //a, body, paraf, charf
	}
}
void ManageSieveCommand::end()
{
    whitespace();
    if ( d->pos >= d->arg.length() )
        return;
    no( "Garbage at end of argument list (pos " + fn( d->pos ) + "): " +
        d->arg.mid( d->pos, 20 ) );
}
Example #9
0
void Fingering::reset()
      {
      QPointF o(userOff());
      score()->layoutFingering(this);
      QPointF no(userOff());
      setUserOff(o);
      score()->undoChangeProperty(this, P_ID::USER_OFF, no);
      }
Example #10
0
int main(){
   struct foo hoo;
   no(1);
   make_null(&hoo);
   make_null(&hoo);

   return 1;
}
Example #11
0
bool ManageSieveCommand::authenticate()
{
    if ( !d->m ) {
        EString t = string().lower();
        EString * r = 0;
        if ( d->arg[d->pos] == ' ' ) {
            whitespace();
            r = new EString( string() );
        }
        end();

        if ( !d->no.isEmpty() )
            return true;

        d->m = SaslMechanism::create( t, this, d->sieve );
        if ( !d->m ) {
            no( "SASL mechanism " + t + " not available" );
            return true;
        }

        d->sieve->setReader( this );
        d->m->readInitialResponse( r );
    }

    if ( d->m->state() == SaslMechanism::AwaitingResponse &&
            d->arg.length() > d->pos )
        d->m->readResponse( new EString( string() ) );

    if ( !d->m->done() || done() )
        return false;

    if ( d->m->state() == SaslMechanism::Succeeded ) {
        d->sieve->setUser( d->m->user(), d->m->name() );
        d->sieve->setState( ManageSieve::Authorised );
    }
    else if ( d->m->state() == SaslMechanism::Terminated ) {
        no( "Authentication terminated" );
    }
    else {
        no( "Authentication failed" );
    }
    d->sieve->setReader( 0 );

    return true;
}
Example #12
0
YesNoMessage::YesNoMessage(const QString& action, QWidget *parent) :
    AskMessage("YesNoMessage", parent),
    ui(new Ui::YesNoMessage)
{
    ui->setupUi(this);
    ui->label->setText("<center>" + tr("Do you really want to ") + action + "</center>");
    connect(ui->yes, SIGNAL(clicked()), SLOT(yes()));
    connect(ui->no, SIGNAL(clicked()), SLOT(no()));
}
Example #13
0
uint ManageSieveCommand::number()
{
    uint i = d->pos;
    while ( d->arg[i] >= '0' && d->arg[i] <= '9' )
        i++;
    if ( i == d->pos )
        no( "Could not find a number at at position " + fn( d->pos ) + ": " +
            d->arg.mid( d->pos, 10 ) );
    bool ok = true;
    uint n = d->arg.mid( d->pos, i-d->pos ).number( &ok );
    if ( !ok )
        no( "Could not parse the number at position " + fn( d->pos ) + ": " +
            d->arg.mid( d->pos, i-d->pos ) );
    d->pos = i;
    if ( d->no.isEmpty() )
        log( "Numeric argument: " + fn( n ), Log::Debug );
    return n;
}
Example #14
0
void RecordConfirmationDialog::noClicked()
{
	emit no();
	if (remember->isChecked())
	{
		settings.setAutoRecord(skypeName, AUTO_RECORD_OFF);
	}
	accept();
}
Example #15
0
value_t operation_identity_compare(value_t a, value_t b,
    cycle_detector_t *outer) {
  if (get_operation_type(a) != get_operation_type(b))
    return no();
  cycle_detector_t inner;
  TRY(cycle_detector_enter(outer, &inner, a));
  return value_identity_compare_cycle_protect(get_operation_value(a),
      get_operation_value(b), &inner);
}
std::string ofxIntegratedWhistleDetector::Whistle::toString() const
{
	if (isNull())
		return std::string("Whistle: Null");

	return "Whistle: #" + ofToString(no()) +
		", Frequency (Hz): " + ofToString(frequency()) +
		", Certainty: " + ofToString(certainty()) +
		", Time (msecs): " + ofToString(msecsPerDuration());
}
Example #17
0
SaveChangesDialog::SaveChangesDialog(const QStringList& files, QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	ui.fileList->addItems(files);

	connect(ui.yes, SIGNAL(clicked()), this, SLOT(yes()));
	connect(ui.no, SIGNAL(clicked()), this, SLOT(no()));
	connect(ui.cancel, SIGNAL(clicked()), this, SLOT(cancel()));
}
Example #18
0
value_t value_identity_compare_cycle_protect(value_t a, value_t b,
    cycle_detector_t *detector) {
  // First check that they even belong to the same domain. Values can be equal
  // across domains.
  value_domain_t a_domain = get_value_domain(a);
  value_domain_t b_domain = get_value_domain(b);
  if (a_domain != b_domain)
    return no();
  // Then dispatch to the domain equals functions.
  switch (a_domain) {
    case vdInteger:
    case vdCustomTagged:
      return new_boolean(is_same_value(a, b));
    case vdHeapObject:
      return heap_object_identity_compare(a, b, detector);
    default:
      return no();
  }
}
Example #19
0
bool ManageSieveCommand::deleteScript()
{
    if ( !d->t ) {
        d->name = string();
        end();
        d->t = new Transaction( this );
        // select first, so the no() calls below work
        d->query =
            new Query( "select active from scripts "
                       "where owner=$1 and name=$2",
                       this );
        d->query->bind( 1, d->sieve->user()->id() );
        d->query->bind( 2, d->name );
        d->t->enqueue( d->query );
        // then delete
        Query * q = new Query( "delete from scripts where owner=$1 and "
                               "name=$2 and active='f'", this );
        q->bind( 1, d->sieve->user()->id() );
        q->bind( 2, d->name );
        d->t->enqueue( q );
        if ( d->no.isEmpty() )
            d->t->commit();
    }

    if ( !d->t->done() )
        return false;

    if ( d->t->failed() ) {
        no( "Couldn't delete script: " + d->t->error() );
    }
    else {
        Row * r = d->query->nextRow();
        if ( !r )
            no( "No such script" );
        else if ( r->getBoolean( "active" ) )
            no( "Can't delete active script" );
        else
            log( "Deleted script " + d->name );
    }

    return true;
}
Example #20
0
int mvInt::interpret(const c3ga &X, int creationFlags /* = 0*/) {
	c3ga I(c3ga::e1 ^ c3ga::e2 ^ c3ga::e3);
	c3ga no(c3ga::no), ni(c3ga::ni);
	c3ga nino(ni ^ no), noni(no ^ ni);

	const GAIM_FLOAT epsilon = 1e-6; // rather arbitrary limit on fp-noise
	c3ga Xd, tmp;

	initToNothing();

	m_type = 0;
	m_type = MVI_C3GA;

	// todo: dualize?


	// check for zero euclidean norm multivectors
	if (X.norm_a() < epsilon) { // *********************** zero blade *******************************
		m_type |= MVI_ZERO;
		m_valid = 1;
		return 0;/*c3gaZero(X); todo */
	}

	// determine the type of the multivectors 
	int grade, type = X.mvType(&grade, epsilon); // temp todo test epsilon

	grade = (int)(log((double)grade) / log((double)2) + 0.45);
	if (creationFlags & OC_BLADE) type = GA_BLADE; // force blade interpretation
	else if (creationFlags & OC_VERSOR) type = GA_VERSOR; // force versor interpretation
	// maybe allow force null, dual, and other properties?
	
	if (type == GA_MULTIVECTOR) {
		m_type |= MVI_UNKNOWN;
		m_valid = 0;

		return 0; /* c3gaUnknown(X); todo */
	}

	if (type == GA_BLADE) { // ************************************* all blades *************************************
		GAIM_FLOAT X2 = (X * X).scalar(), weight2;
		c3ga opniX(ni ^ X), ipniX(ni << X);
		c3ga attitude, pos;

		int X2zero = (fabs(X2) < epsilon);
		int opniXzero = (opniX.norm_a() < epsilon);
		int ipniXzero = (ipniX.norm_a() < epsilon);

		if (opniXzero && ipniXzero) { // *********************** free flat *******************************
			attitude = -(X >> no);
			weight2 = (attitude << attitude).scalar();
			return c3gaFreeFlat(X, grade, attitude, weight2); 
		}
Example #21
0
bool ManageSieveCommand::renameScript()
{
    if ( !d->t ) {
        EString from = string();
        whitespace();
        EString to = string();
        end();
        if ( !d->no.isEmpty() )
            return true;

        d->t = new Transaction( this );
        // select first, so the no() calls below work
        d->query =
            new Query( "update scripts set name=$3 "
                       "where owner=$1 and name=$2",
                       this );
        d->query->bind( 1, d->sieve->user()->id() );
        d->query->bind( 2, from );
        d->query->bind( 3, to );
        d->t->enqueue( d->query );
        d->t->commit();
    }

    if ( !d->t->done() )
        return false;

    if ( d->query->failed() &&
            d->query->error().contains( "scripts_owner_key" ) )
        no( "(ALREADYEXISTS) " + d->t->error() );
    else if ( d->t->failed() )
        no( "Couldn't delete script: " + d->t->error() );
    else if ( d->query->rows() < 1 )
        no( "(NONEXISTENT) No such script" );
    else
        log( "Renamed script" );

    return true;

}
Example #22
0
EString ManageSieveCommand::string()
{
    EString r;
    if ( d->arg[d->pos] == '"' ) {
        uint i = d->pos + 1;
        while ( i < d->arg.length() && d->arg[i] != '"' ) {
            if ( d->arg[i] == '\\' )
                i++;
            r.append( d->arg[i] );
            i++;
        }
        if ( d->arg[i] == '"' )
            i++;
        d->pos = i;
    }
    else if ( d->arg[d->pos] == '{' ) {
        uint pos = d->pos;
        d->pos++;
        uint len = number();
        if ( d->arg.mid( d->pos, 3 ) == "}\r\n" )
            d->pos += 3;
        else if ( d->arg.mid( d->pos, 4 ) == "+}\r\n" )
            d->pos += 4;
        else
            no( "Could not parse literal at position " + fn( pos ) + ": " +
                d->arg.mid( pos, d->pos + 4 - pos ) );
        r = d->arg.mid( d->pos, len );
        d->pos += len;
    }
    else {
        no( "Could not parse string at position " + fn( d->pos ) + ": " +
            d->arg.mid( d->pos, 10 ) );
    }

    if ( d->no.isEmpty() )
        log( "EString argument: " + r, Log::Debug );

    return r;
}
Example #23
0
static value_t heap_object_identity_compare(value_t a, value_t b,
    cycle_detector_t *detector) {
  CHECK_DOMAIN(vdHeapObject, a);
  CHECK_DOMAIN(vdHeapObject, b);
  // Fast case when a and b are the same object.
  if (is_same_value(a, b))
    return yes();
  heap_object_family_t a_family = get_heap_object_family(a);
  heap_object_family_t b_family = get_heap_object_family(b);
  if (a_family != b_family)
    return no();
  family_behavior_t *behavior = get_heap_object_family_behavior(a);
  return (behavior->identity_compare)(a, b, detector);
}
Example #24
0
void setting::save(){
	FILE *f;
	fopen_s(&f, "..\\file\\config.ini", "w");
	double d;
	int i;
	QString n("\n");
	QString yes("T");
	QString no("F");
	QString Q("Quality=");
	QString R("Raft=");
	QString S("Support=");
	QString L("LayerHeight=");
	QString I("Infill=");
	QString N("NumofShells=");
	QString T("Temperature=");
	QString M("ModelHeight=");

	i = ui.Quality->currentIndex()+1;
	QString s = QString::number(i, 10);
	Q = Q + s + n;
	
	if (ui.Raft->isChecked())R = R + yes + n;
	else R = R + no + n;

	if (ui.Support->isChecked())S = S + yes + n;
	else S = S + no + n;

	d = ui.LayerHeight->value();
	L = L + QString::number(d,'g',3) + n;

	i = ui.Infill->value();
	I = I + QString::number(i,10) + n;

	i = ui.NumofShells->value();
	N = N + QString::number(i, 10) + n;

	i = ui.Temperature->value();
	T = T + QString::number(i, 10) + n;

	i = ui.ModelHeight->value();
	M = M + QString::number(i, 10) + n;


	QString result = Q + R + S + L + I + N + T + M;
	fwrite(Qs2c(result), result.length(), 1, f);
	fclose(f);
	this->close();

}
Example #25
0
No *cria_no(int m, int pont_pai, int size, ...)
{
	No *n = no(m, pont_pai);
	int i;
	va_list ap;
	va_start(ap, size);
	for (i = 0; i < n->m + 1; i++) {
		n->p[i] = va_arg(ap, int);
	}
	for (i = 0; i < n->m; i++) {
		n->clientes[i] = va_arg(ap, Cliente *);
	}
	va_end(ap);
	return n;
}
Example #26
0
TEST(plankton, simple) {
  CREATE_RUNTIME();

  // Integers
  check_plankton(runtime, new_integer(0));
  check_plankton(runtime, new_integer(1));
  check_plankton(runtime, new_integer(-1));
  check_plankton(runtime, new_integer(65536));
  check_plankton(runtime, new_integer(-65536));

  // Singletons
  check_plankton(runtime, null());
  check_plankton(runtime, yes());
  check_plankton(runtime, no());

  DISPOSE_RUNTIME();
}
Example #27
0
void repl() {
	char *input;

	while ((input = readline("> ")) != NULL) {
		int ss = stack_size;
	read_start:
		arc_reader_unclosed = 0;
#ifdef READLINE
		if (input && *input)
			add_history(input);
#endif

		char *buf = (char *)malloc(strlen(input) + 4);
		sprintf(buf, "(%s\n)", input);
		const char *p = buf;
		error err;
		atom result;

		atom code_expr;
		err = read_expr(p, &p, &code_expr);
		if (arc_reader_unclosed > 0) { /* read more lines */
			char *line = readline("  ");
			if (!line) break;
			input = strcat_alloc(&input, "\n");
			input = strcat_alloc(&input, line);
			goto read_start;
		}
		if (!err) {
			while (!no(code_expr)) {
				err = macex_eval(car(code_expr), &result);
				if (err) {
					print_error(err);
					break;
				}
				else {
					print_expr(result);
					putchar('\n');
				}
				code_expr = cdr(code_expr);
			}
		}
		stack_restore(ss);
		free(buf);
		free(input);
	}
}
void CContextbookContainer::call_current()
{
	CALLSTACKITEM(_L("CContextbookContainer::call_current"));

	TInt current_index = get_current_idx();
	if (current_index < 0) return;
	TPtrC no( book->get_phone_no(current_index) );

	if (no!=KNullDesC) {
		if (iLog) {
			iLog->write_time();
			iLog->write_to_output(_L("Calling: "));
			iLog->write_to_output(listbox->Model()->ItemTextArray()->MdcaPoint(get_current_idx()));
			iLog->write_nl();
		}
		phone->make_call(no);
	}
}
Example #29
0
int main(int argc, char *argv[]) {
  IMP::setup_from_argv(argc, argv, "Testing protection of particles");
// no checks in fast mode
#if IMP_HAS_CHECKS >= IMP_INTERNAL
  IMP_NEW(IMP::Model, m, ());
  IMP_NEW(IMP::Particle, p, (m));
  IMP::SetNumberOfThreads no(1);
  IMP_NEW(TouchyRestraint, r, (p, IMP::FloatKey(0)));
  try {
    r->evaluate(false);
    // there had better be an exception
    return 1;
    // the exception gets translated into a normal IMP exception
  }
  catch (const std::runtime_error &e) {
    std::cerr << e.what() << std::endl;
  }
#endif
  return 0;
}
Example #30
0
bool ManageSieveCommand::startTls()
{
    if ( d->sieve->hasTls() ) {
        no( "STARTTLS once = good. STARTTLS twice = bad." );
        return true;
    }

    if ( !d->sieve->hasTls() ) {
        end();
        if ( !d->no.isEmpty() )
            return true;

        d->sieve->enqueue( "OK\r\n" );
        d->sieve->startTls();
        d->sieve->capabilities();
        return true;
    }

    return false;
}