Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
// 12. Equation (Version 1) // An + B Log(n) + C n^3 = X // 0 <= A,B, C <= 200, 0 <= X <= 10^15 #include <stdio.h> int A, B, C, T; long long X, N; long long Ans; void input() { scanf("%d%d%d%lld", &A, &B, &C, &X); return; } int log(long long n) { double d = (double) n; int value = 0; while (d >= 2.71828) { d /= 2.71828; value++; } return value; } void output(int t) { printf("#%d %lld\n", t, Ans); } long long fun(long long n) { // if ((A * n) + (B * log(n)) + (C * n * n * n) == X) // return 1; long long value = (A * n) + (B * log(n)) + (C * n * n * n); // printf("VAlue = %d\n", value); return value; } long long binarySearch() { long long up, low, mid; low = 0; up = X; if (0 == C) up = X / A; else up = 100000; mid = (low + up) / 2; while (up > low) { //printf("Up = %d \t Low = %d\t MID = %d\n", up, low, mid); if (fun(mid) > X) { up = mid - 1; } else if (fun(mid) < X) low = mid + 1; else break; mid = (up + low) / 2; } return mid; } int main() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); int i, j, t; scanf("%d", &T); printf("%d\n", T); for (t = 1; t <= T; t++) { input(); Ans = binarySearch(); output(t); } } /* Input ======== 50 54 65 0 1065249 15 80 0 825140 78 45 56 43920106826409 88 33 61 10862481212288 51 16 76 75340716135101 61 80 68 15298476040666 37 96 78 44938769001299 77 8 44 3924571158308 56 8 43 17011168182463 100 71 44 17570901096904 11 66 68 28117566582478 96 38 5 1094101506680 14 47 0 1388015 15 39 0 1224144 68 74 55 451315777889 21 5 91 67383748150925 35 28 75 2035141989774 6 78 21 2631305071992 76 13 85 78855792807390 6 49 26 11039099911984 61 62 0 5278951 4 10 15 109605462904585 91 83 57 3837229109476 92 96 48 38983980235224 85 45 37 23256049751867 97 79 96 11964036473147 53 91 55 16638441356852 98 75 54 12851039806048 81 88 33 23579061196932 70 22 11 3691132858445 59 77 42 15972190135321 95 21 0 6075956 47 20 22 19806806647164 63 19 78 833719207132210 21 10 13 2739764429614 92 88 76 57214773468864 4 4 56 28844376325472 88 5 33 1736061482635 40 16 0 518584 84 49 5 2483025328383 36 11 23 283065394233134 85 42 41 57756572580 85 75 51 23039114493872 53 68 88 533843927607162 86 83 22 15724649965335 77 72 0 186536 97 70 92 56061933307380 91 76 15 3475527788850 68 64 36 12416924320488 31 49 37 6708895527852 */ /* Output ======= 50 #1 19716 #2 54956 #3 9222 #4 5626 #5 9971 #6 6082 #7 8321 #8 4468 #9 7341 #10 7364 #11 7450 #12 6026 #13 99107 #14 81581 #15 2017 #16 9047 #17 3005 #18 5004 #19 9753 #20 7516 #21 86529 #22 19405 #23 4068 #24 9330 #25 8566 #26 4995 #27 6713 #28 6197 #29 8940 #30 6949 #31 7245 #32 63955 #33 9656 #34 22028 #35 5951 #36 9097 #37 8016 #38 3747 #39 12961 #40 7919 #41 23088 #42 1121 #43 7673 #44 18238 #45 8941 #46 2416 #47 8478 #48 6142 #49 7013 #50 5660 */
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Untitled
12 hours ago | 13.15 KB
Analog GPUs: THE FUTURE
17 hours ago | 8.88 KB
Quotes I believe to be true.
17 hours ago | 0.16 KB
Die 7 wichtigsten Aktionen diese Woche
1 day ago | 4.17 KB
Untitled
1 day ago | 13.34 KB
Untitled
1 day ago | 13.59 KB
VNC SCRIPT 2/2: autoinput.vbs
VBScript | 1 day ago | 0.23 KB
VNC SCRIPT 1/2: vncauto.bat
Batch | 1 day ago | 0.72 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!